Пример #1
0
 public void Dispense()
 {
     Console.WriteLine("You're a winner! you get two gumballs for your quarter");
     gumballMachine.releaseBall();
     if (gumballMachine.Count > 0)
     {
         gumballMachine.releaseBall();
         if (gumballMachine.Count > 0)
         {
             gumballMachine.CurrentState = gumballMachine.NoQuarterState;
         }
         else
         {
             Console.WriteLine("Oops,out of gumballs");
             gumballMachine.CurrentState = gumballMachine.SoldOutState;
         }
     }
     else
     {
         gumballMachine.CurrentState = gumballMachine.SoldOutState;
     }
 }
Пример #2
0
 public void Dispense()
 {
     gumballMachine.releaseBall();
     if (gumballMachine.Count > 0)
     {
         gumballMachine.CurrentState = gumballMachine.NoQuarterState;
     }
     else
     {
         Console.WriteLine("Oops,out of gumballs");
         gumballMachine.CurrentState = gumballMachine.SoldOutState;
     }
 }