public void MakeSelectionTest3() { VendingMachine machine = new VendingMachine(); SelectProduct test = new SelectProduct(); test.MakeSelection("B3", 10.00, machine.VendingDictionary["B3"], 0.00); test.MakeSelection("B3", 8.50, machine.VendingDictionary["B3"], 1.50); Assert.AreEqual(3.00, test.TotalSale); Assert.AreEqual(7.00, test.Balance); }
public void VendingMachineTestQuantity() { VendingMachine dictionary = new VendingMachine(); Assert.AreEqual(5, dictionary.VendingDictionary["A1"].Quantity); SelectProduct test = new SelectProduct(); test.MakeSelection("B3", 10.00, dictionary.VendingDictionary["B3"], 0.00); Assert.AreEqual(4, dictionary.VendingDictionary["B3"].Quantity); }
public void RunPurchaseInterface() { Console.WriteLine(); while (finishedPurchase == false) { Console.WriteLine("---------------------------------"); Console.WriteLine("(1) Feed Money"); Console.WriteLine("(2) Select Product"); Console.WriteLine("(3) Finish Transaction"); Console.WriteLine($"Current Money Provided: ${vend.Balance: 0.00}"); Console.WriteLine("---------------------------------"); Console.Write("Please select an option: "); string answer = Console.ReadLine(); switch (answer) { case "1": try { Console.WriteLine(); Console.WriteLine("This machine only takes $1.00, $2.00, $5.00 or $10.00 at a time"); Console.Write("Enter amount of money: $"); moneyIn = double.Parse(Console.ReadLine()); feedMoney.TakeMoney(moneyIn, vend.Balance); vend.Balance = feedMoney.Balance; } catch (Exception e) { Console.WriteLine("Please enter a valid dollar amount."); Console.WriteLine(); } logMethod.WriteToLog("FEED MONEY:", moneyIn, vend.Balance); finishedPurchase = false; break; case "2": try { Console.WriteLine(); Console.Write("Please select a product: "); product = Console.ReadLine().ToUpper(); selectProduct.MakeSelection(product, vend.Balance, vend.VendingDictionary[product], vend.TotalSales); vend.Balance = selectProduct.Balance; vend.TotalSales = selectProduct.TotalSale; } catch (Exception e) { Console.WriteLine("Please enter valid selection."); Console.WriteLine(); } logMethod.WriteToLog($"{product}: {vend.VendingDictionary[product].ItemName}", vend.Balance + vend.VendingDictionary[product].Price, vend.Balance); finishedPurchase = false; break; case "3": giveChange.MakeChange(vend.Balance); vend.Balance = giveChange.Balance; logMethod.WriteToLog("GIVE CHANGE:", giveChange.ChangeDue, vend.Balance); finishedPurchase = true; break; default: Console.WriteLine(); Console.WriteLine("Please make a valid selection"); Console.WriteLine(); finishedPurchase = false; break; } } }