Exemplo n.º 1
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs.");
         gumballMachine.SetState(gumballMachine.GetSoldOutState());
     }
 }
Exemplo n.º 2
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetSoldOutState());
     }
     else
     {
         gumballMachine.ReleaseBall();
         Console.WriteLine("YOU'RE A WINNER! You got two gumballs for your quarter.");
         if (gumballMachine.GetCount() > 0)
         {
             gumballMachine.SetState(gumballMachine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs.");
             gumballMachine.SetState(gumballMachine.GetSoldOutState());
         }
     }
 }
Exemplo n.º 3
0
 public void InsertQuarter()
 {
     Console.WriteLine("You inserted a quarter.");
     gumballMachine.SetState(gumballMachine.GetHasQuarterState());
 }
Exemplo n.º 4
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter ejected.");
     gumballMachine.SetState(gumballMachine.GetNoQuarterState());
 }