コード例 #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());
         }
     }
 }
コード例 #3
0
 public void EjectQuater()
 {
     Console.WriteLine("quarter return");
     this._machine.SetState(_machine.GetNoQuarterState());
 }