Пример #1
0
        public void RemovePizza()
        {
            bool end = false;
            int  select;

            do
            {
                System.Console.WriteLine("Type the number of the pizza to remove or 0 to return");
                System.Console.WriteLine();
                DisplayOrder();
                if (int.TryParse(System.Console.ReadLine(), out select))
                {
                    System.Console.WriteLine();
                }
                else
                {
                    System.Console.WriteLine("Invalid Choice");
                    end = true;
                    continue;
                }
                if ((select > Pizzas.Count || select < 1))
                {
                    System.Console.WriteLine("");
                    end = false;
                }
                else
                {
                    Pizzas.RemoveAt(select - 1);
                    end = false;
                }
            } while (end);
        }
Пример #2
0
        public void RemoveLastPizza()
        {
            if (Pizzas.Count > 0)
            {
                Pizzas.RemoveAt(Pizzas.Count - 1);

                //Re-calculate order price
                Price = CalcOrderPrice();
            }

            else
            {
                System.Console.WriteLine("Cannot remove pizza; no pizzas added yet.");
            }
        }