Пример #1
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.Count > 0)
     {
         gumballMachine.State = gumballMachine.GetNoQuarterState();
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs");
         gumballMachine.State = gumballMachine.GetSoldOutState();
     }
 }
Пример #2
0
 public void Dispense()
 {
     Console.WriteLine("YOU'RE A WINNER! You get two gumballs for your quarter");
     gumballMachine.ReleaseBall();
     if (gumballMachine.Count == 0)
     {
         Console.WriteLine("Oops, out of gumballs");
         gumballMachine.State = gumballMachine.GetSoldOutState();
     }
     else
     {
         gumballMachine.ReleaseBall();
         if (gumballMachine.Count > 0)
         {
             gumballMachine.State = gumballMachine.GetNoQuarterState();
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs");
             gumballMachine.State = gumballMachine.GetSoldOutState();
         }
     }
 }