Exemple #1
0
    static void Checkout(Dictionary <string, int> Cart)
    {
        int    total  = 0;
        Bread  bread  = new Bread();
        Pastry pastry = new Pastry();

        total = bread.GetCost(Cart["bread"]) + pastry.GetCost(Cart["pastry"]);
        Console.WriteLine("Your total for {0} bread and {1} pastry will be ${2}.", Cart["bread"], Cart["pastry"], total);
    }
Exemple #2
0
    // Add integer user input to the Bread or Pastry instance
    private static void ProcessOrder()
    {
        breadOrder.Quantity  += intNumBread;
        pastryOrder.Quantity += intNumPastry;

        intNumBread  = 0;   // Reset input to 0
        intNumPastry = 0;

        // Calculate totals for breads and pastries separately
        breadOrder.GetCost();
        pastryOrder.GetCost();

        DisplayTotal();
    }
        public void EditOrder()
        {
            PrintOrder();
            Console.WriteLine("Which item would you like to edit?");
            string choice = Console.ReadLine().ToLower();

            if ((choice == "bread" || choice == "b") && UserBreads > 0)
            {
                Console.WriteLine("You are editing your bread order. How many loaves would you like to remove? [Enter a number]");
                int amount = int.Parse(Console.ReadLine());
                if (UserBreads >= amount)
                {
                    UserBreads -= Breads.RemoveBread(amount);
                    Console.WriteLine($"Current Bread: ({UserBreads}) loaves for ${Bread.GetCost(UserBreads)}");
                }
                else
                {
                    Console.Write("You cannot remove more bread than you have already ordered.");
                }
            }
            else if (choice == "pastry" || choice == "pastries" || choice == "p")
            {
                Console.WriteLine("You are editing your pastry order. How many pastries would you like to remove? [Enter a number]");
                int amount = int.Parse(Console.ReadLine());
                if (UserPastries >= amount)
                {
                    UserPastries -= Pastries.RemovePastry(amount);
                    Console.WriteLine($"Current Pastries: ({UserPastries}) pastries for ${Pastry.GetCost(UserPastries)}");
                }
                else
                {
                    Console.Write("You cannot remove more pastries than you have already ordered.");
                }
            }
            else if (choice == "nothing" || choice == "x" || choice == "n" || choice == "none")
            {
                Console.Write("Okay. ");
            }
            else
            {
                Console.Write("Please enter a valid input. ");
                EditOrder();
            }
        }
 public int Subtotal()
 {
     return(Bread.GetCost(UserBreads) + Pastry.GetCost(UserPastries));
 }
        public void PlaceOrder()
        {
            Console.WriteLine("What would you like to order?");
            string choice = Console.ReadLine().ToLower();

            if (choice == "bread" || choice == "b")
            {
                Console.WriteLine("How many loaves of bread would you like to order? [Enter a number]");
                int amount = int.Parse(Console.ReadLine());
                UserBreads += Breads.OrderBread(amount);
                Console.WriteLine($"Current Bread: ({UserBreads}) loaves for ${Bread.GetCost(UserBreads)}");
            }
            else if (choice == "pastry" || choice == "pastries" || choice == "p")
            {
                Console.WriteLine("How many pastries would you like to order? [Enter a number]");
                int amount = int.Parse(Console.ReadLine());
                UserPastries += Pastries.OrderPastry(amount);
                Console.WriteLine($"Current Pastries: ({UserPastries}) pastries for ${Pastry.GetCost(UserPastries)}");
            }
            else if (choice == "nothing" || choice == "x" || choice == "n")
            {
                Console.Write("Okay. Would you like to continue? ");
                if (ContinueOrExit())
                {
                    CustomersChoice();
                }
            }
            else
            {
                Console.Write("Please enter a valid input. ");
                PlaceOrder();
            }
        }