public GumballMachine(int number) { noQuarterState = new NoQuarterState(this); hasQuarterState = new HasQuaterState(this); soldOutState = new SoldOutState(this); soldState = new SoldState(this); count = number; if (number > 0) { state = noQuarterState; } }
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; } }