Esempio n. 1
0
        public void PaymentChoice(double grandTotal)
        {
            bool paymentReturn = true;

            while (paymentReturn == true)
            {
                Console.WriteLine("How will you be paying today? cash, card, or check?");
                string paymentChoice = Console.ReadLine().ToLower();
                if (paymentChoice == "cash")
                {
                    paymentReturn = false;
                    PaymentValidation.Cash(grandTotal);
                }
                else if (paymentChoice == "card")
                {
                    PaymentValidation.Credit(grandTotal);
                    paymentReturn = false;
                }
                else if (paymentChoice == "check")
                {
                    PaymentValidation.Check(grandTotal);
                    paymentReturn = false;
                }
                else
                {
                    Console.WriteLine("Sorry, I didn't understand, please write 'cash' 'card' or 'check'.");
                    paymentReturn = true;
                }
            }
        }
        static void Main(string[] args)
        {
            PaymentValidation payValidation = new PaymentValidation();
            Checkout          checkout      = new Checkout();
            bool finalAnswer = true;

            while (finalAnswer == true)
            {
                checkout = DisplayMenu(checkout);
                checkout.PaymentChoice(checkout.GrandTotal);
                PrintReceipt(checkout, checkout.GrandTotal, checkout.Tax, checkout.SubTotal);
                bool isValid = true;
                while (isValid == true)
                {
                    Console.WriteLine("Would you like to make another transaction? y/n");
                    string inputYorN = Console.ReadLine().ToLower();
                    if (inputYorN == "y")
                    {
                        checkout.Cart.Clear();
                        checkout.GrandTotal = 0;
                        checkout.Tax        = 0;
                        checkout.SubTotal   = 0;
                        Console.Clear();
                        finalAnswer = true;
                        isValid     = false;
                    }
                    else if (inputYorN == "n")
                    {
                        Console.WriteLine("Have a great day!");
                        finalAnswer = false;
                        isValid     = false;
                    }
                    else
                    {
                        Console.WriteLine("Invalid try again");
                        isValid = true;
                    }
                }
            }
        }