示例#1
0
        public void AmountOfMoneyAdded_MatchesCurrentMoneyProvided()
        {
            test.AddMoney(5.00M);
            test.AddMoney(1.00M);
            test.AddMoney(10.00M);

            Assert.AreEqual(16.00M, test.CurrentMoneyProvided);
        }
示例#2
0
        private static void FeedMoneyMenu()
        {
            while (true)
            {
                CircusOf();
                string[] menu    = { "Please Insert Money:", "(1)  $1", "(2)  $2", "(5)  $5", "(10) $10", "(20) $20", "(D)one Inserting Money", $"Money Inserted: ${machine.CurrentMoneyProvided}" };
                int      longest = menu.Max(x => x.Length);

                PrintMenusSingleSpaced(menu);


                if (machine.ShoppingCart.Count > 0)
                {
                    Console.SetCursorPosition((Console.WindowWidth - longest) / 2, Console.CursorTop);

                    Console.WriteLine($"Current Total: ${machine.TotalCart}");
                }
                Value();
                string answer = Console.ReadLine();

                decimal moneyInserted;
                decimal.TryParse(answer, out moneyInserted);


                if (moneyInserted == 1 || moneyInserted == 2 || moneyInserted == 5 ||
                    moneyInserted == 10 || moneyInserted == 20)
                {
                    Console.Clear();
                    machine.AddMoney(moneyInserted);
                    machine.PrintLog("FEED MONEY: $" + moneyInserted + "     $" + machine.CurrentMoneyProvided.ToString());
                }
                else if (answer.ToUpper() == "D" || answer.ToUpper() == "Done" || answer.ToLower() == "D" || answer.ToLower() == "Done")
                {
                    Console.Clear();
                    MainMenu();
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine($"{moneyInserted} is not a valid denomination. Please select one of the values below.");
                    Console.WriteLine();
                }
            }
        }