Exemplo n.º 1
0
 public GumballMachineContext(uint numBalls = 0)
 {
     _quartersController = new QuartersController(MaxQuartersLimit);
     _count           = numBalls;
     _soldState       = new SoldState(this);
     _soldOutState    = new SoldOutState(this);
     _noQuarterState  = new NoQuarterState(this);
     _hasQuarterState = new HasQuarterState(this);
     _state           = (_count > 0) ? _noQuarterState : (IState)_soldOutState;
 }
Exemplo n.º 2
0
 public GumballMachine(uint count = 0)
 {
     _quartersController = new QuartersController(MaxQuartersLimit);
     _state = (count > 0 ? State.NoQuarter : State.SoldOut);
     _count = count;
 }