public override void Dispense() { Console.WriteLine("YOU'RE A WINNER! You get two gumballs for your quarter"); try { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() == 0) { gumballMachine.SetState(gumballMachine.GetSoldOutState()); } else { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.SetState(gumballMachine.GetSoldOutState()); } } } catch (Exception e) { throw e; } }
public override void Dispense() { gumballMachine.ReleaseBall(); try { if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.SetState(gumballMachine.GetSoldOutState()); } } catch (Exception e) { throw e; } }
public void Report() { Console.WriteLine("Gumball Machine: " + machine.GetLocation()); Console.WriteLine("Current inventory: " + machine.GetCount() + " gumballs"); Console.WriteLine("Current state: " + machine.GetState()); }