Пример #1
0
        public void DestroyPizza(int i)
        {
            i = i - 1;
            Pizza  p          = Pizzas[i];
            double removeCost = p.ComputePricing();

            Pizzas.RemoveAt(i);
            NumberOfPizzasOrdered = NumberOfPizzasOrdered - 1;
            TotalCostOfOrder      = TotalCostOfOrder - removeCost;
        }
Пример #2
0
 public void removePizza(int pizzaIndex)
 {
     if (pizzaIndex < 0 || pizzaIndex > Pizzas.Count - 1)
     {
         throw new Exception("Pizza out of bounds! Tried to remove a pizza index not in the range of pizzas.");
     }
     else
     {
         Pizzas.RemoveAt(pizzaIndex);
     }
 }
Пример #3
0
 public bool DeletePizza(int index)
 {
     try
     {
         Pizzas.RemoveAt(index);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #4
0
        public bool LimitCheck()
        {
            const int     maxPizzas = 50;
            const decimal maxBill   = 250M;

            if (Pizzas.Count > maxPizzas || ComputePricing() > maxBill)
            {
                Console.WriteLine($"Order limit reached (max pizzas {maxPizzas}, max cost {maxBill}) pizza not added");
                Pizzas.RemoveAt(Pizzas.Count - 1);
                return(true);
            }
            return(false);
        }
Пример #5
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!");
            }
        }
Пример #6
0
 public Pizza RemovePizza(int Id)
 {
     Pizzas.RemoveAt(Id);
     return(Pizzas[Id]);
 }
 public void RemovePizzaAt(int index)
 {
     Pizzas.RemoveAt(index - 1);
 }