public void Init() { _vendingMachine = new VendingMachineObj(); _bankAccount = new BankAccount(); _cashCardA = new CashCard(_bankAccount); _cashCardB = new CashCard(_bankAccount); }
private void BuyCans(int cansnumber, ICashCard card, int pinCode) { while (cansnumber > 0) { _vendingMachine.BuyCan(card, pinCode); cansnumber--; } }
public void ProcessOrder(ICashCard cashCard, int pin, int quantity) { if (VerifyAccount(cashCard.Account, pin)) { _orderManager.UpdateAccountAndInventory(this, quantity); } else { throw new InvalidAccountCredentialsException(); } }
public void BuyCan(ICashCard cashCard, int pin) { if (pin == cashCard.PinCode) { lock (this) { if (_inventory > 0) { cashCard.WithdrawFromAccount(CAN_PRICE); _inventory--; } } Console.WriteLine("Correct pin"); } else { Console.WriteLine("Wrong pin"); } Console.WriteLine(string.Format("Cans remaining: {0}", CansInventory)); }
public User(ICashCard cashCardA, ICashCard cashCardB) { CashCardA = cashCardA; CashCardB = cashCardB; }
private void BuyCansWithCorrectPin(int cansnumber, ICashCard card) { BuyCans(cansnumber, card, card.PinCode); }
private void BuyCansWithInCorrectPin(int cansnumber, ICashCard card) { var differentPin = card.PinCode == 1000 ? 1001 : 1000; BuyCans(cansnumber, card, differentPin); }