//methods public void RunSimulation() { while (sodaMachine.inventory.Count > 0) { customer.DisplayCurrentStatus(); sodaMachine.DisplayInventory(); int choice = customer.SelectSoda(); bool isInInventory = sodaMachine.CheckInventory(choice); Coin coin; if (isInInventory == true) { do { double value = sodaMachine.GetTemporaryRegister(); coin = customer.InputCoins(value); if (coin != null) { sodaMachine.AddToTemporaryRegister(coin); } } while (coin != null); Can can = sodaMachine.CompleteTransaction(choice); if (can != null) { customer.AddToBackpack(can); } List <Coin> change = sodaMachine.ReturnMoney(); customer.AddChangeToWallet(change); sodaMachine.ClearTemporaryRegister(); } } }
public void SelectSoda() { UserMenu.DisplayMenuAndPrices(); string sodaSelected = UserMenu.EnterSelection(); bool machineHasSoda = sodaMachine.CheckInventory(sodaSelected); if (machineHasSoda) { InsertCoinsForPurchase(); CheckAmountInTemporaryRegister(); if (temporaryRegister.>= canCost) { //adds coins to the temp register //need to see if the coins that are inside the temp register are enough for the soda selected //^^^^^for this we need to compare cost of soda found to money in temp register //if it's enough dispense soda //if more than and enough change in the machine, give change and dispense soda. //if not enough, start select soda again sodaMachine.DispenseSoda(sodaSelected); } } else { SelectSoda(); } }