static void FridgeFunc() { Fridge fridge1 = new Fridge(); fridge1.IsOn = true; fridge1.Temperature = 4; FridgeItem milk = new FridgeItem { Name = "Milk" }; FridgeItem bread = new FridgeItem { Name = "Bread" }; FridgeItem beer = new FridgeItem { Name = "Polarized Karhu" }; Console.WriteLine(fridge1.AddItem(milk)); Console.WriteLine(fridge1.AddItem(milk)); Console.WriteLine(fridge1.AddItem(milk)); Console.WriteLine(fridge1.AddItem(bread)); Console.WriteLine(fridge1.AddItem(bread)); Console.WriteLine(fridge1.AddItem(bread)); for (int i = 0; i < 18; i++) { Console.WriteLine(fridge1.AddItem(beer)); } Console.WriteLine(fridge1.PrintAll()); }
public string AddItem(FridgeItem item) { if (ItemQuantity < MaxItems) { Items.Add(item); ItemQuantity++; return("New item " + item.Name + " added to fridge"); } else { return("Error! Max item quantity reached!"); } }