Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
 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!");
     }
 }