public void AddToPayment(Coin coinToAdd) { if (!WalletHasCoin(coinToAdd)) { Interface.DisplayMessage("Insufficient coins in wallet for this selection. Please try again."); } else { wallet.coins.Remove(coinToAdd); payment.Add(coinToAdd); Interface.DisplayMessage($"Your current total payment is: {Computations.ComputeTotalPayment(payment)}"); } }
public void AssessPayment(Customer customer, Can canSelection) { double totalPayment = Math.Round(Computations.ComputeTotalPayment(customer.payment), 2); double paymentChange = totalPayment - canSelection.Cost; if (totalPayment < canSelection.Cost) { Interface.DisplayMessage("Insufficient money provided. Soda will not be dispensed and funds will be returned."); customer.AddToWallet(customer.payment); } else if (!MachineHasCan(canSelection)) { Interface.DisplayMessage("Insufficient soda in inventory. Soda will not be dispensed and funds will be returned."); customer.AddToWallet(customer.payment); } else if (paymentChange > ComputeRegisterValue()) { Interface.DisplayMessage("Insufficient change in machine. Soda will not be dispensed and funds will be returned."); customer.AddToWallet(customer.payment); } else if (totalPayment >= canSelection.Cost && (MachineHasCan(canSelection))) { if (NeedsChange(totalPayment, canSelection)) { double changeToDispense = Math.Round(totalPayment - canSelection.Cost, 2); DispenseSoda(canSelection); Interface.DisplayMessage($"Your change is {changeToDispense}"); customer.backpack.AddCan(canSelection); customer.AddToWallet(ComputeChangeList(changeToDispense)); } else { DispenseSoda(canSelection); customer.backpack.AddCan(canSelection); } } }