I have a class of products and a machine manager class. Inside the machine manager class I have a private list of products with a getter and setter, I can access the list, but all of the properties inside the list are still private, so I cannot manipulate them in anyway.
Here is what I am trying to do
private List<Product> productsInsideMachine { get; set; }
When I try accessing the properties I get the error: inaccessible due to protection level.
//Retrieve all available proucts in machine
public void ListAvailableProducts()
{
foreach (var product in productsInsideMachine)
{
Console.WriteLine(product.productName);
}
}
One of the priorities of this exercise is to practice with private fields
Here is the product class
private string productName { get; set; }
private int productPrice { get; set; }
private int productQuantity { get; set; }
//Constructor
public Product(string name, int cost, int quantity)
{
productName = name;
productPrice = cost;
productQuantity = quantity;
}