public void Dispense() { Console.WriteLine("CONGRATULATIONS, WE HAVE A WINNER!"); Console.WriteLine("Releasing Free Gumball!"); if (Machine.GetCount() == 0) { Machine.SetGumballState(Machine.GetSoldOutState()); } else { Console.WriteLine("Releasing Gumball!"); if (Machine.GetCount() > 0) { Machine.SetGumballState(Machine.GetNoQuarterState()); } else { Console.WriteLine("Ooops, out of Gumballs..."); Machine.SetGumballState(Machine.GetSoldOutState()); } } }
public void Dispense() { if (Machine.GetCount() > 0) { Console.WriteLine("Dispensing Gumball..."); Machine.SetGumballState(Machine.GetNoQuarterState()); } else { Console.WriteLine("Oops, we're out of Gumballs!"); Machine.SetGumballState(Machine.GetSoldOutState()); } }