Пример #1
0
        public static void TotalPrice()
        {
            string receiptHead;

            receiptHead = (
                $@"              

                       ____________________________________________________________
                      |        ################
                      |        ###Items List###
                      |        ################
                      |    ");
            Console.WriteLine(receiptHead);
            // int breadTypeCount = 0;
            // decimal breadTotal = 0m;
            // int pastryTypeCount = 0;
            // decimal pastryTotal = 0m;
            //int pastryTypeCount = 0;

            decimal       breadDiscount  = Bread.CalculateBreadDiscount();
            decimal       breadPrice     = Bread.TotalBreadPrice();
            decimal       newBreadTotal  = breadPrice - breadDiscount;
            List <string> breadReceipt   = Bread.GenerateBreadReceipt();
            decimal       pastryDiscount = Pastry.CalculatePastryDiscount();
            decimal       pastryPrice    = Pastry.TotalPastryPrice();
            decimal       newPastryPrice = pastryPrice - pastryDiscount;
            List <string> pastryReceipt  = Pastry.GeneratePastryReceipt();
            List <string> receipt        = new List <string> {
            };

            receipt.Add(receiptHead);


            decimal totalPricetag = newPastryPrice + newBreadTotal;

            foreach (string b in breadReceipt)
            {
                Console.WriteLine(b);
                receipt.Add(b);
            }

            foreach (string p in pastryReceipt)
            {
                Console.WriteLine(p);
                receipt.Add(p);
            }
            string priceString = (
                $@"                      |                                                                                                                                
                      |  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   
                      |                                                                                                                            
                      |   Your total bread price before discounts is: ${breadPrice}          
                      |   Your total bread price after discounts is: ${newBreadTotal}           
                      |   Your total pastry price before discounts is: ${pastryPrice}          
                      |   Your total pastry price after discount is: ${newPastryPrice}            
                      |   --                                                          
                      |   Your total price is: ${totalPricetag}                                
                      |   --                                                          
                      |   You saved ${breadDiscount} on bread!                                   
                      |   You saved ${pastryDiscount} on pastries!                                 
                       ---------------------------------------------------------------");

            Console.WriteLine(priceString);

            receipt.Add(priceString);

            Console.WriteLine($"Would you like to save this receipt? [y/n]");
            if (Console.ReadLine().ToLower() == "y")
            {
                PrintReceipt(receipt);
            }
            else
            {
                Console.ReadLine();
                Console.ResetColor();
            }
        }