public void Dispense() { Console.WriteLine("You are a winner! You get two gumballs for your quarter"); _machine.ReleaseBall(); if (_machine.GetCount() == 0) { _machine.SetState(_machine.GetSoldOutState()); } else { _machine.ReleaseBall(); if (_machine.GetCount() > 0) { _machine.SetState(_machine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); _machine.SetState(_machine.GetSoldOutState()); } } }
public void TurnCrank() { _machine.ReleaseBall(); if (_machine.GetCount() > 0) { _machine.SetState(_machine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); _machine.SetState(_machine.GetSoldOutState()); } }