Beispiel #1
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.GetSoldOut());
     }
     else
     {
         gumballMachine.ReleaseBall();
         if (gumballMachine.GetCount() > 0)
         {
             gumballMachine.SetState(gumballMachine.GetNoQuarter());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs");
             gumballMachine.SetState(gumballMachine.GetSold());
         }
     }
 }
Beispiel #2
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarter());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs");
         gumballMachine.SetState(gumballMachine.GetSoldOut());
     }
 }