Exemplo n.º 1
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());
     }
 }
Exemplo n.º 2
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());
         }
     }
 }
Exemplo n.º 3
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.SetState(gumballMachine.GetNoQuarter());
 }