001package headfirst.state.gumballstate;
002
003public class HasQuarterState implements State {
004        GumballMachine gumballMachine;
005
006        public HasQuarterState(GumballMachine gumballMachine) {
007                this.gumballMachine = gumballMachine;
008        }
009
010        public void insertQuarter() {
011                System.out.println("You can't insert another quarter");
012        }
013
014        public void ejectQuarter() {
015                System.out.println("Quarter returned");
016                gumballMachine.setState(gumballMachine.getNoQuarterState());
017        }
018
019        public void turnCrank() {
020                System.out.println("You turned...");
021                gumballMachine.setState(gumballMachine.getSoldState());
022        }
023
024        public void dispense() {
025                System.out.println("No gumball dispensed");
026        }
027
028        public String toString() {
029                return "waiting for turn of crank";
030        }
031}