Exemplo n.º 1
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Ooops , out of gumballs");
         gumballMachine.SetState(gumballMachine.GetsoldOutState());
     }
 }
Exemplo n.º 2
0
 public void Dispense()
 {
     Console.WriteLine("YOU'RE A 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 gumballs!");
             _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
         }
     }
 }
Exemplo n.º 3
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.SetState(gumballMachine.GetNoQuarterState());
 }