Exemple #1
0
 public void Dispense()
 {
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.GetCount() > 0)
     {
         _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs");
         _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
     }
 }
Exemple #2
0
 public void Dispense()
 {
     Console.WriteLine("YOU ARE THE WINNER! You get two gumballs for your quarter!");
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.GetCount() == 0)
     {
         _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
     }
     else
     {
         _gumballMachine.ReleaseBall();
         if (_gumballMachine.GetCount() > 0)
         {
             _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballsasd");
             _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
         }
     }
 }