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()); } }
//Method Exclusive to SoldOutState public void Refill(int gumballs) { if (gumballs > 0) { //Set Machin Gum Balls Machine.SetCount(gumballs); //Transition State to back in action Machine.SetGumballState(Machine.GetNoQuarterState()); } }
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 EjectQuarter() { Console.WriteLine("Ejecting Quarter!"); Machine.SetGumballState(Machine.GetNoQuarterState()); }
public void InsertQuarter() { Console.WriteLine("Quarter Inserted!"); Machine.SetGumballState(Machine.GetHasQuarterState()); }