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()); } }
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 TurnCrank() { Console.WriteLine("Turning Crank!"); int winner = random.Next(0, 10); if ((winner == 0) && (Machine.GetCount() > 1)) { Machine.SetGumballState(Machine.GetWinnerState()); } else { Machine.SetGumballState(Machine.GetSoldState()); } }