예제 #1
0
 public void dispense() {
   gumballMachine.releaseBall();
   if (gumballMachine.getCount() > 0) {
     gumballMachine.setState(gumballMachine.getNoQuarterState());
   } else {
     System.out.println("Oops, out of gumballs!");
     gumballMachine.setState(gumballMachine.getSoldOutState());
   }
 }
예제 #2
0
 public void dispense() {
   gumballMachine.releaseBall();
   if (gumballMachine.getCount() > 0) {
     gumballMachine.setState(gumballMachine.getNoQuarterState());
   } else {
     System.out.println("PANIC WE SOLD ALL BALLS!");
     gumballMachine.setState(gumballMachine.getSoldOutState());
   }
 }
 public void dispense() {
   gumballMachine.releaseBall();
   try {
     if (gumballMachine.getCount() > 0) {
       gumballMachine.setState(gumballMachine.getNoQuarterState());
     } else {
       System.out.println("Oops, out of gumballs!");
       gumballMachine.setState(gumballMachine.getSoldOutState());
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #4
0
 public void dispense() {
   System.out.println("YOU'RE A WINNER! You get two gumballs 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 {
       System.out.println("Oops, out of gumballs!");
       gumballMachine.setState(gumballMachine.getSoldOutState());
     }
   }
 }
예제 #5
0
 @Override
 public void ejectQuarter() {
   System.out.println("Quarter returned");
   gumballMachine.setState(gumballMachine.getNoQuarterState());
 }
 public void refill() {
   gumballMachine.setState(gumballMachine.getNoQuarterState());
 }
예제 #7
0
 @Override
 public void ejectQuarter() {
   System.out.println("Quarter ejected");
   this.machine.setState(machine.getNoQuarterState());
 }