Пример #1
0
 /** @see org.suggs.sandbox.patterns.behavioural.state.gumball.IState#turnCrank() */
 @Override
 public void turnCrank() {
   LOG.info("You have turned the crank");
   int winner = randomWinner.nextInt(10);
   if ((winner == 0) && gumballMachine.getCount() > 1) {
     gumballMachine.setState(gumballMachine.getWinnerState());
   } else {
     gumballMachine.setState(gumballMachine.getSoldState());
   }
 }
Пример #2
0
 /** @see org.suggs.sandbox.patterns.behavioural.state.gumball.IState#ejectQuarter() */
 @Override
 public void ejectQuarter() {
   LOG.info("Quarter returned");
   gumballMachine.setState(gumballMachine.getNoQuarterState());
 }