public void Dispense() { _gumballMachine.ReleaseBall(); bool noGumballs = false; if (_gumballMachine.Count > 0) { _gumballMachine.ReleaseBall(); Console.WriteLine("YOU'RE A WINNER! You've got two gumballs for your quarter."); if (_gumballMachine.Count > 0) { _gumballMachine.SetState(_gumballMachine.NoQuarterState); } else { noGumballs = true; } } else { noGumballs = true; } if (noGumballs) { Console.WriteLine("Oops, out of gumballs!"); _gumballMachine.SetState(_gumballMachine.SoldOutState); } }
public void Dispense() { _gumballMachine.ReleaseBall(); if (_gumballMachine.Count > 0) { _gumballMachine.SetState(_gumballMachine.NoQuarterState); } else { Console.WriteLine("Oops, out of gumballs!"); _gumballMachine.SetState(_gumballMachine.SoldOutState); } }
public void EjectQuarter() { Console.WriteLine("Quarter returned."); _gumballMachine.SetState(_gumballMachine.NoQuarterState); }
public void InsertQuarter() { Console.WriteLine("You inserted a quarter."); _gumballMachine.SetState(_gumballMachine.HasQuarterState); }
public void Refill() { _gumballMachine.SetState(_gumballMachine.NoQuarterState); }