예제 #1
0
 public GumballMachine(int numberGumballs)
 {
     SoldOutState    = new SoldOutState(this);
     NoQuarterState  = new NoQuarterState(this);
     HasQuarterState = new HasQuarterState(this);
     SoldState       = new SoldState(this);
     WinnerState     = new WinnerState(this);
     Count           = numberGumballs;
     if (numberGumballs > 0)
     {
         State = NoQuarterState;
     }
 }
예제 #2
0
 public GumballMachine(string location, int count)
 {
     State           = SoldOutState;
     Count           = count;
     Location        = location;
     NoQuarterState  = new NoQuarterState(this);
     HasQuarterState = new HasQuarterState(this);
     SoldOutState    = new SoldOutState(this);
     SoldState       = new SoldState(this);
     WinnerState     = new WinnerState(this);
     if (count > 0)
     {
         State = NoQuarterState;
     }
 }