示例#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()
 {
     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());
         }
     }
 }
示例#3
0
 public void ejectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.setState(gumballMachine.getNoQuarterState());
 }
示例#4
0
 public void refill()
 {
     gumballMachine.setState(gumballMachine.getNoQuarterState());
 }
示例#5
0
 public void insertQuarter()
 {
     Console.WriteLine("You inserted a quarter!");
     gumballMachine.setState(gumballMachine.getHasQuarterState());
 }