コード例 #1
0
        //Prompts user for Pastry Order amount and returns pastry order cost
        private static int HandlePastryOrder()
        {
            Console.WriteLine("\nHow many pastries would you like to purchase?");
            int pastryCount = GetOrder();

            if (pastryCount % 2 == 0 && pastryCount > 0)
            {
                Console.WriteLine("Would you like an additional pastry for only $1?");
                Console.WriteLine("Please submit 'Yes' or 'No'");
                string upsellResponse = Console.ReadLine();

                if (upsellResponse == "Y" || upsellResponse == "Yes" || upsellResponse == "y" || upsellResponse == "yes")
                {
                    pastryCount++;
                    Console.WriteLine("Thank you for your patronage!");
                }
            }

            Pastries pastryOrder = new Pastries(pastryCount);
            int      pastryCost  = pastryOrder.Cost();

            Console.WriteLine("You have selected {0} pastries for ${1}", pastryOrder.PastryCount, pastryCost);
            Console.WriteLine("______________________________");

            return(pastryCost);
        }
コード例 #2
0
        public static void Order(string item)
        {
            item.ToUpper();
            string result = "";

            if (item == "BREAD")
            {
                Console.WriteLine("\n" + "How many loaf(s) of bread would you like to purchase?");

                int order = int.Parse(Console.ReadLine());

                Console.WriteLine("------------------------------------- \n");
                Bread bread = new Bread(order);
                bread.BreadCost();
            }

            else if (item == "PASTRIES")
            {
                Console.WriteLine("\n" + "How many pastries would you like to purchase?");

                int order = int.Parse(Console.ReadLine());

                Console.WriteLine("------------------------------------- \n");
                Pastries pastry = new Pastries(order);
                pastry.PastryCost();
            }

            else
            {
                Console.WriteLine("\n" + "Please type BREAD or PASTRIES \n");
                result = Console.ReadLine();
                Order(result.ToUpper());
            }
        }
コード例 #3
0
        public void BuildMenu()
        {
            Random rnd       = new Random();
            int    numBread  = rnd.Next(1, 10);
            int    numPastry = rnd.Next(1, 10);

            int i = 0;

            while (i < numBread)
            {
                Bread newBread = new Bread();
                if (newBread.Type != null)
                {
                    Breads.Add(newBread);
                }
                i++;
            }

            int j = 0;

            while (j < numPastry)
            {
                Pastry newPastry = new Pastry();
                if (newPastry.Type != null)
                {
                    Pastries.Add(newPastry);
                }
                j++;
            }
        }
コード例 #4
0
        static void Main()
        {
            int totalPrice = 0;

            Console.WriteLine("Hello, welcome to Pierre's Bakery.");
            Console.WriteLine("Bread is $5 a loaf, and has a buy 2 get 1 free deal!");
            Console.WriteLine("Pastries, are only $2 each and have a 3 for $5 deal!");
            Console.WriteLine(" ▄▄▄·▪  ▄▄▄ .▄▄▄  ▄▄▄  ▄▄▄ ..▄▄ ");
            Console.WriteLine("▐█ ▄███ ▀▄.▀·▀▄ █·▀▄ █·▀▄.▀·▐█ ▀.");
            Console.WriteLine(" ██▀·▐█·▐▀▀▪▄▐▀▀▄ ▐▀▀▄ ▐▀▀▪▄▄▀▀▀█");
            Console.WriteLine("▐█▪·•▐█▌▐█▄▄▌▐█•█▌▐█•█▌▐█▄▄▌▐█▄▪▐█");
            Console.WriteLine(".▀   ▀▀▀ ▀▀▀ .▀  ▀.▀  ▀ ▀▀▀  ▀▀▀▀");
            Console.WriteLine("How many loaves of bread would you like?");
            string breadOrdered = Console.ReadLine();
            int    priceOfBread;
            bool   canOrderBread = int.TryParse(breadOrdered, out priceOfBread);

            if (canOrderBread && int.Parse(breadOrdered) >= 1)
            {
                int   breadToOrder = int.Parse(breadOrdered);
                Bread breadOrder   = new Bread(breadToOrder);
                Console.WriteLine("That will be: $" + breadOrder.Price() + " for the bread.");
                totalPrice += breadOrder.Price();
            }
            else
            {
                Console.WriteLine("Please enter a valid number.");
            }
            Console.WriteLine("How many pastries would you like?");
            string pastriesOrdered = Console.ReadLine();
            int    priceOfPastries;
            bool   canOrderPastries = int.TryParse(pastriesOrdered, out priceOfPastries);

            if (canOrderPastries && int.Parse(pastriesOrdered) >= 1)
            {
                int      pastriesToOrder = int.Parse(pastriesOrdered);
                Pastries pastriesOrder   = new Pastries(pastriesToOrder);
                Console.WriteLine("That will be: $" + pastriesOrder.Price() + " for the pastries.");
                totalPrice += pastriesOrder.Price();
            }
            else
            {
                Console.WriteLine("Please enter a valid number.");
            }
            Console.WriteLine("Your total today comes to: $" + totalPrice);
            Console.WriteLine("Will that be all for you today? Y/N");
            string userResponse = Console.ReadLine();

            if (userResponse == "N")
            {
                Main();
            }
            else
            {
                Console.WriteLine("Goodbye!");
            }
        }
コード例 #5
0
        public void PastriesTotal_CalculatePriceWithDiscount_int()
        {
            //Arrange
            Pastries TestPastries = new Pastries();

            //Act
            TestPastries.Count = 6;

            //Assert
            Assert.AreEqual(10, TestPastries.Total);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: jordanHS/PierresBakery
        public static void Main()
        {
            Console.WriteLine("Welcome to your Pierre's Bakery!");
            Console.WriteLine("Bread is $5 per loaf and pastries are $2 each");
            Bread myBread = new Bread(0);

            Console.WriteLine("How many loaves would you like? (Please use numbers only)");
            myBread.BreadQuantity = int.Parse(Console.ReadLine());
            Pastries myPastries = new Pastries(0);

            Console.WriteLine("How many pastries would you like?");
            myPastries.PastryQuantity = int.Parse(Console.ReadLine());
            Console.WriteLine("You bought {0} loaves of bread and {1} pastries.", myBread.BreadQuantity, myPastries.PastryQuantity);
            int    orderTotal  = myBread.GetTotal() + myPastries.GetTotal();
            string stringTotal = orderTotal.ToString();

            Console.WriteLine("Your total is $" + stringTotal + "! Have a great day!");
        }
コード例 #7
0
        public static void Main()
        {
            Loaves   MyBread  = new Loaves();
            Pastries MyPastry = new Pastries();

            Console.WriteLine("");
            Console.WriteLine("WelCome. We are selling 12 seeds Delicious Killer Bread Loaves and Lemon Tart Pastries");
            MyBread.LoavesOrderGetter();
            MyPastry.PastryOrderGetter();
            Dictionary <int, float> OrderKeeper = new Dictionary <int, float>();

            OrderKeeper.Add(11, MyBread.TotalPrice);
            OrderKeeper.Add(12, MyPastry.TotalPrice);
            float FirstOrderTotal = OrderKeeper[11] + OrderKeeper[12];

            Console.WriteLine("");
            Console.WriteLine("Your Current Order total for both Loaves and pastries is" + " " + FirstOrderTotal);
            Console.WriteLine("");
            Console.WriteLine("You sure you are done? Want to buy more? Input Y for the second order");
            string SecondOrder = Console.ReadLine();

            if (SecondOrder == "Y" || SecondOrder == "y")
            {
                MyBread.LoavesOrderGetter();
                MyPastry.PastryOrderGetter();
                OrderKeeper.Add(21, MyBread.TotalPrice);
                OrderKeeper.Add(22, MyPastry.TotalPrice);
                float SecondOrderTotal = OrderKeeper[21] + OrderKeeper[22];
                Console.WriteLine("");
                Console.WriteLine("Your second Order total for both Loaves and pastries is" + " " + SecondOrderTotal);
                float GrandTotal = OrderKeeper[11] + OrderKeeper[12] + OrderKeeper[21] + OrderKeeper[22];
                Console.WriteLine("");
                Console.WriteLine("Your Grand Total for both the orders is: $" + GrandTotal);
            }
            else
            {
                Console.WriteLine("Have a Wonderful Day and Please Come again");
            }
        }
コード例 #8
0
        [TestMethod] // Are pastries real
        public void PastriesChecker_TestShouldTellIfPastriesExists_PastriesIsReal()
        {
            Pastries pastriesTest = new Pastries(600);

            Assert.AreEqual(typeof(Pastries), pastriesTest.GetType());
        }
コード例 #9
0
        [TestMethod] // Do they have discount free pricing for sub3
        public void PastriesPricer2_ShouldHaveNormalPriceOf2_DeliciousPastries()
        {
            Pastries pastriesTest = new Pastries(2);

            Assert.AreEqual(4, pastriesTest.Price());
        }
コード例 #10
0
        [TestMethod] // What are their price?
        public void PastriesPricer_TestShouldTellPriceOfPastries_PastriesHavePrice()
        {
            Pastries pastriesTest = new Pastries(32);

            Assert.AreEqual(54, pastriesTest.Price());
        }
コード例 #11
0
        [TestMethod] // How many pastries?
        public void PastriesChecker_TestShouldTellNumberOfPastries_PastriesHasNumber()
        {
            Pastries pastriesTest = new Pastries(30);

            Assert.AreEqual(30, pastriesTest.AmountOfPastries);
        }
コード例 #12
0
 public void PastriesConstructor_CreatesInstanceOfPastries_PastriesObject()
 {
   Pastries testPastry = new Pastries(3);
   Assert.AreEqual(typeof(Pastries), testPastry.GetType());
 }
コード例 #13
0
 public void Cost_ReturnsPriceOfOrderWithDiscount_Int()
 {
   Pastries testPastry = new Pastries(3);
   Assert.AreEqual(5, testPastry.Cost());
 }
コード例 #14
0
 public void Cost_ReturnsPriceOfOrder_Int()
 {
   Pastries testPastry = new Pastries(2);
   Assert.AreEqual(4, testPastry.Cost());
 }
コード例 #15
0
 public void PastriesConstructor_CreatesInstanceOfPastriesWithPastryCount_Int()
 {
   Pastries testPastry = new Pastries(3);
   Assert.AreEqual(3, testPastry.PastryCount);
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: HoldenJC/bakery-c
        static Pastries addPastries(string item)
        {
            Pastries pastry = new Pastries(item);

            return(pastry);
        }