Exemplo n.º 1
0
        public void RemovePizza(int pizzaIdNumber)
        {
            if (Pizzas.ElementAt(pizzaIdNumber) != null)
            {
                // Remove pizza at index
                Pizzas.RemoveAt(pizzaIdNumber);
                // Remove all null pizzas from the order

                /* Clarification: If we just remove a pizza from the order, then that index will just be null.
                 * This would cause some issues with the order count, since there would then be x-1 pizzas, but
                 * the program would still just think there are x pizzas. Gotta be safe! */
                Pizzas = Pizzas.Where(pizza => pizza != null).ToList();
                foreach (var pizza in Pizzas)
                {
                    pizza.PizzaID = Pizzas.IndexOf(pizza);
                }
                Value = RecalculateValue();
            }
            else
            {
                Console.WriteLine("There are no pizzas in this order!");
            }
        }