Exemple #1
0
        private void FeedMoney()
        {
            int     input;
            string  choice = "";
            decimal total  = vendingMachine.customerBalance;

            while (choice.ToUpper() != "B")
            {
                Console.WriteLine();
                Console.WriteLine("Current Balance: $" + total);
                Console.WriteLine("Insert Bill: ($1, $2, $5, $10) ");
                Console.WriteLine("Press B to return to Purchase Menu");
                Console.Write("Choice: ");

                choice = Console.ReadLine();

                if (choice.ToUpper() == "B")
                {
                    choice = choice.ToUpper();
                }
                else
                {
                    input = int.Parse(choice);

                    if (input == 1 || input == 2 || input == 5 || input == 10)
                    {
                        total += input;
                        vendingMachine.AuditTransaction(input, total);
                    }
                    else
                    {
                        Console.WriteLine("Invalid Bill Type");
                    }
                }
            }
            vendingMachine.customerBalance = total;
        }