public void DispenseStock(int stockId, StockItemList stockItemList, CardSlot cardSlot, Keypad keypad, ChangeDispenser changeDispenser, Display display, BalanceSystem balanceSystem) { List <StockItem> calledList = stockItemList.GetList(); for (int i = 0; i < calledList.Count; i++) { if ((stockId - 1) == calledList[i].GetId() && (cardSlot.cardInserted == true || balanceSystem.balance >= calledList[i].GetPrice())) { Console.WriteLine("Item has been dispensed."); balanceSystem.Balance(-calledList[i].GetPrice()); } else if ((stockId - 1) == calledList[i].GetId() && (cardSlot.cardInserted == true || balanceSystem.balance < calledList[i].GetPrice())) { Console.WriteLine("Not enough money has been deposited to buy this item."); } } Console.WriteLine("Type 'again' to buy another item, or press enter to dispense your remaining balance."); if (keypad.TakeInput() == "again") { display.DisplayBalance(balanceSystem); display.DisplayStock(); DispenseStock(keypad.TakeStockItem(), stockItemList, cardSlot, keypad, changeDispenser, display, balanceSystem); } else { changeDispenser.DispenseChange(balanceSystem); Console.ReadLine(); } }
public void TakePayment(BalanceSystem balanceSystem) { balanceSystem.Balance(Math.Round(Convert.ToDecimal(_keypad.TakeBalance(_display)), 2)); _display.DisplayBalance(balanceSystem); }