Ejemplo 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());
     }
 }
Ejemplo 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());
         }
     }
 }
Ejemplo n.º 3
0
 public void InsertQuarter()
 {
     Console.WriteLine("You insert a quarter");
     gumballMachine.SetState(gumballMachine.GetHasQuarter());
 }
Ejemplo n.º 4
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.SetState(gumballMachine.GetNoQuarter());
 }