public void Dispense() { _machine.ReleaseBall(); if (_machine.GetCount() > 0) { _machine.SetState(_machine.GetNoQuarterState()); } else { Console.WriteLine("Sold out of gumballs"); _machine.SetState(_machine.GetSoldOutState()); } }
public void Dispense() { _machine.ReleaseBall(); if (_machine.GetCount() == 0) { _machine.SetState(_machine.GetSoldOutState()); } else { _machine.ReleaseBall(); Console.WriteLine("Congratulations! You are a winner"); if (_machine.GetCount() == 0) { _machine.SetState(_machine.GetSoldOutState()); Console.WriteLine("Sold out of gumballs"); } else { _machine.SetState(_machine.GetNoQuarterState()); } } }
public void Refill() { Console.WriteLine("Refilling gumballs"); _machine.SetState(_machine.GetNoQuarterState()); }
public void InsertQuarter() { Console.WriteLine("Inserting a quarter"); _machine.SetState(_machine.GetHasQuarterState()); }