コード例 #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;
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Rlemuel1992/MidTermPOS
        static void Main(string[] args)
        {
            PaymentValidation payValidation = new PaymentValidation();
            Checkout          checkout      = new Checkout();
            string            finalAnswer   = "y";

            while (finalAnswer == "y")
            {
                checkout = DisplayMenu(checkout);
                checkout.PaymentChoice(checkout.GrandTotal);
                PrintReceipt(checkout, checkout.GrandTotal, checkout.Tax, checkout.SubTotal);
                Console.WriteLine("Would you like to make another transaction? y/n");
                finalAnswer = Console.ReadLine().ToLower();
                if (finalAnswer == "y")
                {
                    checkout.SubTotal   = 0;
                    checkout.Tax        = 0;
                    checkout.GrandTotal = 0;
                    checkout.Cart.Clear();
                    continue;
                }
                else if (finalAnswer == "n")
                {
                    Console.WriteLine("Have a great day!");
                    Environment.Exit(1);
                }
            }
        }
コード例 #3
0
        public double GrandTotal()
        {
            PaymentValidation c          = new PaymentValidation();
            double            subTotal   = SubTotal();
            double            tax        = SalesTaxTotal();
            double            grandTotal = subTotal + tax;

            return(grandTotal);
        }
コード例 #4
0
        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;
                    }
                }
            }
        }