public void FeedMoney() { bool exit = false; while (!exit) { Console.Clear(); Console.WriteLine("Enter the corresponding number to increase current money provided..."); Console.WriteLine("1) $1\n2) $2 \n3) $5 \n4) $10"); Console.WriteLine($"Current Money Provided: {_vendingMachine.Money.ToString("C")}"); Console.WriteLine("Press \'q\' and enter if you would like to go back"); char input = Console.ReadKey().KeyChar; if (input == '1' || input == '2' || input == '3' || input == '4') { if (input == '1') { _vendingMachine.AddMoney(VendingMachine.MoneySelection.OneDollar); } if (input == '2') { _vendingMachine.AddMoney(VendingMachine.MoneySelection.TwoDollar); } if (input == '3') { _vendingMachine.AddMoney(VendingMachine.MoneySelection.FiveDollar); } if (input == '4') { _vendingMachine.AddMoney(VendingMachine.MoneySelection.TenDollar); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"\nThank you. Current Money: {_vendingMachine.Money.ToString("C")}"); Console.Beep(200, 1000); Console.ResetColor(); } else if (input == 'q' || input == 'Q') { exit = true; } else { Console.WriteLine("That was not an option... Please Try again"); } } }
public void VendingMachineTestMoney10() { //Add Money 10 checked VendingMachine vm = new VendingMachine(); vm.AddMoney(VendingMachine.MoneySelection.TenDollar); Assert.AreEqual(10, vm.Money, "10 more dollars was added"); }
public void VendingMachineTestMoney5() { //Add Money 5 checked VendingMachine vm = new VendingMachine(); vm.AddMoney(VendingMachine.MoneySelection.FiveDollar); Assert.AreEqual(5, vm.Money, "5 more dollars was added"); }
public void VendingMachineTestMoney2() { //Add Money 2 checked VendingMachine vm = new VendingMachine(); vm.AddMoney(VendingMachine.MoneySelection.TwoDollar); Assert.AreEqual(2, vm.Money, "2 more dollars was added"); }
public void VendingMachineTest() { VendingMachine vm = new VendingMachine(); //itemDict Key + Product name works var inventory = vm.GetInventory(); Assert.AreEqual("Potato Crisps", inventory["A1"].ProductName, "Should return Potato Crisps"); Assert.AreEqual(1.80, inventory["B1"].Price, "Price of moonpies should be 1.80"); Assert.AreEqual("Gum", inventory["D2"].Type, "Gum is the type of Little League Chew"); //Add Money 1 checked vm.AddMoney(VendingMachine.MoneySelection.OneDollar); Assert.AreEqual(1, vm.Money, "Only one dollar was added"); //Add Money 2 on top of Money 1 checked vm.AddMoney(VendingMachine.MoneySelection.TwoDollar); Assert.AreEqual(3, vm.Money, "2 more dollars was added"); }
public static void SecondMenu() { bool j = true; while (j) { Console.Clear(); Console.WriteLine(@" ______ _ ___ __ | ___ \ | | \ \ / / | |_/ / | | |\ V / | ___ \ | | | \ / | |_/ / |_| | | | \____/ \___/ \_/ "); Console.WriteLine(); Console.WriteLine("1) Feed Money"); Console.WriteLine(); Console.WriteLine("2) Select Product"); Console.WriteLine(); Console.WriteLine("3) Finish Transaction"); Console.WriteLine(""); Console.WriteLine($"Current Money Provided: ${vendingMachine.Current()}"); string input = Console.ReadLine(); switch (input) { case "1": Console.Clear(); Console.WriteLine(@" /$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$__ $$/$$__ $$/$$__ $$ | $$ \__/ $$ \__/ $$ \__/ | $$$$$$| $$$$$$| $$$$$$ \____ $$\____ $$\____ $$ /$$ \ $$/$$ \ $$/$$ \ $$ | $$$$$$/ $$$$$$/ $$$$$$/ \_ $$_/ \_ $$_/ \_ $$_/ \__/ \__/ \__/ "); Console.WriteLine("Enter $ amount 1, 2, 5,or 10: "); Console.Write("$"); string amount = Console.ReadLine(); vendingMachine.AddMoney(amount); break; case "2": Console.Clear(); Console.WriteLine(@" ______ _ _ | ___ \ | | | | | |_/ / __ ___ __| |_ _ ___| |_ ___ | __/ '__/ _ \ / _` | | | |/ __| __/ __| | | | | | (_) | (_| | |_| | (__| |_\__ \ \_| |_| \___/ \__,_|\__,_|\___|\__|___/ "); vendingMachine.SelectProduct(); string choice = Console.ReadLine().ToUpper(); vendingMachine.Choose(choice); break; case "3": Console.Clear(); Console.WriteLine(@" /$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$__ $$/$$__ $$/$$__ $$ | $$ \__/ $$ \__/ $$ \__/ | $$$$$$| $$$$$$| $$$$$$ \____ $$\____ $$\____ $$ /$$ \ $$/$$ \ $$/$$ \ $$ | $$$$$$/ $$$$$$/ $$$$$$/ \_ $$_/ \_ $$_/ \_ $$_/ \__/ \__/ \__/ "); string result = vendingMachine.FinishTransaction(); Console.WriteLine(result); Console.ReadLine(); j = false; break; } } }