예제 #1
0
 // Calculates and prints reciept
 public static void CompleteOrder()
 {
     bread.CalculateOrder();
     pastries.CalculateOrder();
     Console.Clear();
     RollingConsoleWrite($"Your total is: ${bread.TotalCost + pastries.TotalCost}\nBread: {bread.Quantity}\nPastries: {pastries.Quantity}\nThank you for your purchase!\n");
     ValidateInput("Would you like to:\n'restart' or 'quit'\n", "restart", MainMenu);
 }
        public void BreadCalculator_CalculatesBreadOrders_Int()
        {
            Bread newBread = new Bread();

            newBread.AddItems(20);
            newBread.CalculateOrder();
            Assert.AreEqual(95, newBread.TotalPrice);
        }
예제 #3
0
        public void CalculateOrder_CalculateTotalCostOf3Breads_15()
        {
            Bread newBread = new Bread();

            newBread.AddItems(3);
            newBread.CalculateOrder();
            Assert.AreEqual(15, newBread.TotalCost);
        }
예제 #4
0
        public static void Main()
        {
            Console.WriteLine("Welcome to Pierre's Boulangerie!");
            Console.WriteLine("We have two items for sale,");
            Console.WriteLine("Bread or Pastries");
            Console.WriteLine("Bread is $5 for a loaf; buy two, get one free.");
            Console.WriteLine("Pastries are $2 each, or 3 for $5.");
            Console.WriteLine("Would you like some bread? (yes or no)");
            string breadBuy = Console.ReadLine().ToLower();

            if (breadBuy == "yes")
            {
                Console.WriteLine("How many loaves of bread can I get for you today?");
                string breadOrder = Console.ReadLine().ToLower();
                Bread  newBread   = new Bread();
                newBread.AddItems(int.Parse(breadOrder));
                newBread.CalculateOrder();
                Console.WriteLine("Your bread order comes to: $" + newBread.TotalPrice);

                Console.WriteLine("Would you like some pastries? (yes or no)");
                string pastryBuy = Console.ReadLine().ToLower();
                if (pastryBuy == "yes")
                {
                    Console.WriteLine("How many pastries would you like?");
                    string pastryOrder = Console.ReadLine().ToLower();
                    Pastry newPastry   = new Pastry();
                    newPastry.AddItems(int.Parse(pastryOrder));
                    newPastry.CalculateOrder();
                    Console.WriteLine("Your pastry order comes to: $" + newPastry.TotalPrice);
                    Console.WriteLine("Would you care for anything else (yes or no)");
                    string finalAnswer = Console.ReadLine().ToLower();
                    if (finalAnswer == "yes")
                    {
                        Main();
                    }
                    else
                    {
                        int grandTotal = newPastry.TotalPrice + newBread.TotalPrice;
                        Console.WriteLine("Thanks, for coming in today.");
                        Console.WriteLine("Your grand total comes to: $" + grandTotal);
                    }
                }
            }
            else
            {
                Console.WriteLine("Thanks for coming to smell the fresh-baked bread. Have a nice day.");
            }
        }