Пример #1
0
 public void TurnCrank()
 {
     _machine.ReleaseBall();
     if (_machine.GetCount() > 0)
     {
         _machine.SetState(_machine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs!");
         _machine.SetState(_machine.GetSoldOutState());
     }
 }
Пример #2
0
 public void Dispense()
 {
     Console.WriteLine("You are a winner! You get two gumballs for your quarter");
     _machine.ReleaseBall();
     if (_machine.GetCount() == 0)
     {
         _machine.SetState(_machine.GetSoldOutState());
     }
     else
     {
         _machine.ReleaseBall();
         if (_machine.GetCount() > 0)
         {
             _machine.SetState(_machine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             _machine.SetState(_machine.GetSoldOutState());
         }
     }
 }
 public void EjectQuater()
 {
     Console.WriteLine("quarter return");
     this._machine.SetState(_machine.GetNoQuarterState());
 }