Example #1
0
        public void CalculatePastryCost_CalculatesTotalCostOfPastries_Int()
        {
            int    numOfPastries    = 5;
            Pastry firstPastryOrder = new Pastry(numOfPastries);

            Assert.AreEqual(9, firstPastryOrder.CalculatePastryCost(5));
        }
        public void CalculatePastryCost_CalculatesCostOfPastryOrderInput0_void()
        {
            Pastry newPastry = new Pastry(0);

            newPastry.CalculatePastryCost();
            Assert.AreEqual(0, newPastry.Cost);
        }
Example #3
0
        public void CalculatePastryCostIfDeal_ReturnPastryCostWithDiscount_Double()
        {
            int    amount    = 7;
            double price     = 2;
            Pastry newPastry = new Pastry(price, true);

            double result = newPastry.CalculatePastryCost(amount);

            Assert.AreEqual((amount / 3) * (price - 1) + (amount - amount / 3) * price, result);
        }
Example #4
0
        public void CalculatePastryCost_ReturnPastryCost_Double()
        {
            double price     = 2.99;
            Pastry newPastry = new Pastry(price);
            int    amount    = 3;

            double result = newPastry.CalculatePastryCost(amount);

            Assert.AreEqual(amount * price, result);
        }
Example #5
0
    public static void Main()
    {
        Bread  bakeryBread  = new Bread();
        Pastry bakeryPastry = new Pastry();

        while (true)
        {
            OutputMenu();
            PurchaseSequence();
            WriteLine("Are you ready to checkout? (y/n)");
            string response = ReadLine();
            if (response.ToLower() == "y")
            {
                _total += bakeryBread.CalculateBreadCost(itemsOrdered["bread"]);
                _total += bakeryPastry.CalculatePastryCost(itemsOrdered["pastry"]);
                WriteLine("-----------------------");
                WriteLine($"Your total is ${_total}");
                WriteLine("-----------------------");
                break;
            }
        }
    }
Example #6
0
        public void SingleLoaf_BreadCostTest()
        {
            int costForOneLoaf = testPastry.CalculatePastryCost(1);

            Assert.AreEqual(2, costForOneLoaf);
        }
Example #7
0
 static double CalculateTotalCost(int breadAmount, int pastryAmount, Bread newBread, Pastry newPastry)
 {
     return(newBread.CalculateBreadCost(breadAmount) + newPastry.CalculatePastryCost(pastryAmount));
 }
Example #8
0
    public static void Main()
    {
        //Assortiment and prices adjustments
        double breadPrice = 5;
        Bread  newBread   = new Bread(breadPrice, true);

        double pastryPrice = 2;
        Pastry newPastry   = new Pastry(pastryPrice, true);

        //Announcements for user
        Console.WriteLine("Welcome to the Pierre's Bakery!");
        Console.WriteLine("Our pricelist: Bread for $" + breadPrice + " and Pastry for $" + pastryPrice);

        if (newBread.BreadDealMarker == true || newPastry.PastryDealMarker == true)
        {
            Console.Write("Our deals today:\n");
            if (newBread.BreadDealMarker == true)
            {
                Console.WriteLine("Buy 2 loafs of bread, get 1 loaf free.");
            }
            if (newPastry.PastryDealMarker == true)
            {
                Console.WriteLine("Buy 1 Pastry for $" + pastryPrice + " or 3 for $" + newPastry.CalculatePastryCost(3));
            }
        }

        //Interaction with user
        Console.WriteLine("Would you like to buy something today? ['Y' for yes, 'Enter' for no]");
        string ifBuyer = Console.ReadLine();

        if (ifBuyer.ToLower() == "y")
        {
            int breadAmount = InputtedBreadAmount();
            if (breadAmount >= 0)
            {
                int pastryAmount = InputtedPastryAmount();
                if (pastryAmount >= 0)
                {
                    double result = CalculateTotalCost(breadAmount, pastryAmount, newBread, newPastry);
                    Console.WriteLine("Total cost of your order: $" + result);
                }
            }
        }
        else
        {
            Console.WriteLine("Are you finished for today? ['Y' for yes, 'Enter' for no]");
            string finishedAnswer = Console.ReadLine();
            if (finishedAnswer.ToLower() == "y")
            {
                Console.WriteLine("Goodbye.");
            }
            else
            {
                Main();
            }
        }
    }
Example #9
0
        public void CalculateCost_CalculateSevenPastryOrderCost_Integer()
        {
            Pastry pastry = new Pastry("croissant", 7, 2);

            Assert.AreEqual(12, pastry.CalculatePastryCost());
        }
Example #10
0
        public void CalculateCost_CalculateThreePastryOrderCost_Integer()
        {
            Pastry pastry = new Pastry("croissant", 3, 2);

            Assert.AreEqual(5, pastry.CalculatePastryCost());
        }