public GumballMachine(int count) { SoldOutState = new SoldOutState(this); NoQuarterState = new NoQuarterState(this); HasQuarterState = new HasQuarterState(this); SoldState = new SoldState(this); Count = count; if (Count > 0) { StateController = NoQuarterState; } else { StateController = SoldOutState; } }
public GumballMachine(int gumballsNumber) { NoQuarterState = new NoQuarterState(this); HasQuarterState = new HasQuarterState(this); SoldState = new SoldState(this); SoldOutState = new SoldOutState(this); WinnerState = new WinnerState(this); GumballsCount = gumballsNumber; if (gumballsNumber > 0) { CurrentState = NoQuarterState; } else { CurrentState = SoldOutState; } }