Пример #1
0
        static void Main()
        {
            Console.WriteLine("Welcome to Pierre's Bakery! Today we have our famous country loaf for $5 or if you buy 2 you get 1 free. We also have the always delightful berry danish for $2 or 3 for $5.");
            Console.WriteLine("How many loaves of bread would you like?");
            string strLoaves  = Console.ReadLine();
            Bread  breadOrder = new Bread(int.Parse(strLoaves));

            if (breadOrder.Loaves % 3 == 2)
            {
                Console.WriteLine("Are you sure you wouldn't like to get one more loaf? It would be free with our buy 2 get 1 free deal. If you would like to add another loaf press ['Y' for yes] or press ['Enter' for no].");
                string moreBread = Console.ReadLine();
                if (moreBread == "Y" || moreBread == "y")
                {
                    breadOrder.AddLoaf();
                }
            }
            breadOrder.TotalBread();
            if (breadOrder.Loaves >= 12)
            {
                breadOrder.AddLoaf();
                Console.WriteLine("Thanks for being such a great customer! Here's a loaf on me!");
            }
            Console.WriteLine("And how many pastries can I get you today?");
            string strPastries = Console.ReadLine();
            Pastry pastryOrder = new Pastry(int.Parse(strPastries));

            if (pastryOrder.Pastries % 3 == 2)
            {
                Console.WriteLine("Are you sure you wouldn't like to get one more pastry? It would cost only $1 more! If you would like to add another pastry press ['Y' for yes] or press ['Enter' for no].");
                string anotherPastry = Console.ReadLine();
                if (anotherPastry == "Y" || anotherPastry == "y")
                {
                    pastryOrder.AddPastry();
                }
            }
            pastryOrder.TotalPastries();
            if (pastryOrder.Pastries >= 12)
            {
                pastryOrder.AddPastry();
                Console.WriteLine("Thanks for being such a great customer! I threw and extra pastry in there for you!");
            }
            Console.WriteLine($"So that's {breadOrder.Loaves} loa{(breadOrder.Loaves == 1 ? "f" : "ves")} for ${breadOrder.BreadTotal} and {pastryOrder.Pastries} pastr{(pastryOrder.Pastries == 1 ? "y" : "ies")} for ${pastryOrder.PastryTotal} your total comes to ${breadOrder.BreadTotal + pastryOrder.PastryTotal}. Is that all for you today? Press ['Y' for yes] or press ['Enter' for no].");
            string finalQuestion = Console.ReadLine();

            if (finalQuestion == "Y" || finalQuestion == "y")
            {
                Console.WriteLine("Thank you so much for visiting Pierre's! We look forward to your next visit!");
            }
            else
            {
                Main();
            }
        }
Пример #2
0
        public static void Main()
        {
            Console.WriteLine("Welcome to Royal Bakery!");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("What is your name?");
            string custName = Console.ReadLine();

            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("Here is our menu:");
            Console.WriteLine("--Chocolate Babka: $5/loaf or buy 2, get one free");
            Console.WriteLine("--Black and White Cookie: $2 for 1 or 3 for $5");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("Please enter the number of bread loaves you would like.");

            int   breadQty   = int.Parse(Console.ReadLine());
            Bread breadOrder = new Bread(breadQty);
            int   breadTotal = breadOrder.CalcBread(breadQty);

            Console.WriteLine("Please enter the number of cookies would you like.");

            int    pastryQty   = int.Parse(Console.ReadLine());
            Pastry pastryOrder = new Pastry(pastryQty);
            int    pastryTotal = pastryOrder.CalcPastry(pastryQty);

            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("Would you like to add anything else? [press 'Y' for yes or 'N' to cancel]");

            string userAdd = Console.ReadLine();

            if (userAdd == "y" || userAdd == "Y")
            {
                Console.WriteLine("How many loaves of bread would you like to add?");
                int breadAdd      = int.Parse(Console.ReadLine());
                int breadAddTotal = breadOrder.AddBread(breadAdd);

                Console.WriteLine("How many cookies would you like to add?");
                int pastryAdd      = int.Parse(Console.ReadLine());
                int pastryAddTotal = pastryOrder.AddPastry(pastryAdd);

                Console.WriteLine("-------------------------------------------------");
                Console.WriteLine("Thank you for your order, " + custName + ". Your total is $" + (breadAddTotal + pastryAddTotal) + ".");
                Console.WriteLine("-------------------------------------------------");
            }
            else if (userAdd == "n" || userAdd == "N")
            {
                Console.WriteLine("-------------------------------------------------");
                Console.WriteLine("Thank you for your order, " + custName + ". Your total is $" + (breadTotal + pastryTotal) + ".");
                Console.WriteLine("-------------------------------------------------");
            }
            else
            {
                Console.WriteLine("Please choose a valid response.");
                Console.WriteLine("-------------------------------");
            }
        }