コード例 #1
0
        public void ChangeCalculatorEndingBalance()
        {
            decimal balance = 0;

            CashRegister.ChangeWithLeastAmountOfCoins();

            Assert.AreEqual(0M, CashRegister.balance);

            balance = 10M;
            CashRegister.ChangeWithLeastAmountOfCoins();
            Assert.AreEqual(0M, CashRegister.balance);

            balance = 1500M;
            CashRegister.ChangeWithLeastAmountOfCoins();
            Assert.AreEqual(0M, CashRegister.balance);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: azichbrad/VendingMachine
        public static void PurchaseMenu()
        {
            Console.Clear();
            Console.WriteLine("---- Purchasing Menu ----");
            Console.WriteLine("Please select a number 1 - 3 for the following menu options.");
            Console.WriteLine($"Current balance: {CashRegister.balance:C2}");
            Console.WriteLine();
            Console.WriteLine("(1) Feed Money");
            Console.WriteLine("(2) Select Product");
            Console.WriteLine("(3) Finish Transaction");
            string purchaseMenuSelect = Console.ReadLine();

            if (purchaseMenuSelect == "1")
            {
                Menu.TakeMoneyMenu();
                // unsure if we want to ask amounts here or elsewhere, if so will do another method to encompass that
            }
            else if (purchaseMenuSelect == "2")
            {
                VendingMachine.VendingSelection();
                // Show list of products available and Customer Enters a code to select.
                //if code doesnt exist return info and back to PurchaseMenu()
                //if sold out, informed then returned to PurchaseMenu()
                //if valid product selected it is dispensed:
            }
            else if (purchaseMenuSelect == "3")
            {
                CashRegister.ChangeWithLeastAmountOfCoins();
                AuditLog.UpdateAuditLog(VendingMachine.newAuditEntries);
                Console.ReadKey();
                //Customer finalizes all transactions and is returned to the MainMenu()
                //return change - using fewest coins using division and modulus probably
                //Machine current balance should be udpated to 0$ remaining
                //salesLog updated here or in option 2

                MainMenu();
            }
            else
            {
                Console.WriteLine("Not a valid menu selection");
                PurchaseMenu();
            }
        }