示例#1
0
 public static void AddTopping(Location l, Pizza p, string topping, string ans, PizzaStoreRepository repo)
 {
     if (ans == "y")
     {
         if (l.Inventory[topping] > 0)
         {
             //p.Toppings.Add(topping);
             //$1 toppings
             p.Price++;
             l.Inventory[topping]--;
             p.Toppings[topping] = true;
             repo.UpdateInventory(l);
             repo.Save();
             Console.WriteLine($"Current toppings for the {p.PizzaSize} pizza is: ");
             foreach (KeyValuePair <string, bool> entry in p.Toppings)
             {
                 if (entry.Value == true)
                 {
                     Console.WriteLine(entry.Key);
                 }
             }
         }
         else
         {
             Console.WriteLine("Sorry, we currently do not have that topping in stock.");
             Console.WriteLine($"{topping} was NOT added.");
         }
     }
 }