public void Dispense() { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarter()); } else { Console.WriteLine("Oops, out of gumballs"); gumballMachine.SetState(gumballMachine.GetSoldOut()); } }
public void Dispense() { Console.WriteLine("You're a winner! You get two gumballs for your quarter"); gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() == 0) { gumballMachine.SetState(gumballMachine.GetSoldOut()); } else { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarter()); } else { Console.WriteLine("Oops, out of gumballs"); gumballMachine.SetState(gumballMachine.GetSold()); } } }
public void EjectQuarter() { Console.WriteLine("Quarter returned"); gumballMachine.SetState(gumballMachine.GetNoQuarter()); }