public GumBallMachine(int numOfGums) { SoldOutState = new SoldOutState(this); NoQuarterState = new NoQuarterState(this); HasQuarterState = new HasQuarterState(this); SoldState = new SoldState(this); WinnerState = new WinnerState(this); GumCount = numOfGums; if (GumCount > 0) { _state = NoQuarterState; } }
public GumballMachine(int numberGumballs) { soldOutState = new SoldOutState(this); noQuarterState = new NoQuarterState(this); hasQuarterState = new HasQuarterState(this); soldState = new SoldState(this); this.count = numberGumballs; if (numberGumballs > 0) { State = noQuarterState; } }
public GumballMachine(int numberOfGumballs = 0) { SoldOutState = new SoldOutState(this); NoQuarterState = new NoQuarterState(this); HasQuarterState = new HasQuarterState(this); SoldState = new SoldState(this); WinnerState = new WinnerState(this); Count = numberOfGumballs; if (numberOfGumballs > 0) { State = NoQuarterState; } else { State = SoldOutState; } }