Example #1
0
 public void Dispense()
 {
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.Count > 0)
     {
         _gumballMachine.State = _gumballMachine.NoQuarterState;
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs!");
         _gumballMachine.State = _gumballMachine.SoldOutState;
     }
 }
Example #2
0
 public void Dispense()
 {
     Console.WriteLine("YOU'RE A WINNER! You get two balls for you quarter");
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.Count == 0)
     {
         _gumballMachine.State = _gumballMachine.SoldOutState;
     }
     else
     {
         _gumballMachine.ReleaseBall();
         if (_gumballMachine.Count > 0)
         {
             _gumballMachine.State = _gumballMachine.NoQuarterState;
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             _gumballMachine.State = _gumballMachine.SoldOutState;
         }
     }
 }