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 override void InsertQuarter() { Console.WriteLine("You inserted a quarter"); gumballMachine.SetState(gumballMachine.GetHasQuarterState()); }
public override void EjectQuarter() { Console.WriteLine("Quarter returned"); gumballMachine.SetState(gumballMachine.GetNoQuarterState()); }