コード例 #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());
     }
 }
コード例 #2
0
 public void Dispense()
 {
     Console.WriteLine("YOU'RE A WINNER! You get two balls for your quarter");
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() == 0)
     {
         gumballMachine.SetState(gumballMachine.GetSoldOutState());
     }
     else
     {
         gumballMachine.ReleaseBall();
         if (gumballMachine.GetCount() > 0)
         {
             gumballMachine.SetState(gumballMachine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             gumballMachine.SetState(gumballMachine.GetSoldOutState());
         }
     }
 }
コード例 #3
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.SetState(gumballMachine.GetNoQuarterState());
 }