示例#1
0
        public void FeedMoney()
        {
            string previousAmountPaid = "$0.00";

            while (true)
            {
                Console.WriteLine("Press [1] to add 1 dollar.");
                Console.WriteLine("Press [2] to add 2 dollars.");
                Console.WriteLine("Press [3] to add 5 dollars.");
                Console.WriteLine("Press [4] to add 10 dollars.");
                Console.WriteLine("Press [C] to confirm payment");
                Console.WriteLine("Press [Q] to cancel selections. Return to main menu.");
                userPayment = Console.ReadLine().ToUpper();
                if (userPayment == "C")
                {
                    if (vm.DidUserPayEnough())
                    {
                        Console.Clear();
                        DisplayChangeAndEndTransaction();
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Please insert more money before confirming payment.");
                        DisplayAmountDueAndAmountPaid();
                        FeedMoney();
                    }
                }
                else if (userPayment == "Q")
                {
                    ClearSelectionsPayments();
                    MainMenu();
                }
                amountPaid = vm.AddMoney(userPayment).ToString("C");
                fw.WriteToLog("FEED MONEY", previousAmountPaid, amountPaid);
                previousAmountPaid = amountPaid;
                Console.Clear();
                DisplayAmountDueAndAmountPaid();
            }
        }