public VendingMachine()
 {
     NoCoinState  = new NoCoinState();
     HasCoinState = new HasCoinState();
     SoldState    = new SoldState();
     SoldOutState = new SoldOutState();
     capacity     = 10;
 }
Exemplo n.º 2
0
 public GumballMachine(int gumballs)
 {
     WinnerState     = new WinnerState(this);
     SoldState       = new SoldState(this);
     SoldOutState    = new SoldOutState(this);
     NoQuarterState  = new NoQuarterState(this);
     HasQuarterState = new HasQuarterState(this);
     _count          = gumballs;
     _currentState   = _count > 0 ? NoQuarterState : SoldOutState;
 }
Exemplo n.º 3
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;
     State           = numberGumballs > 0 ? NoQuarterState : SoldOutState;
 }
 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;
     }
 }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        public GumballMachine(int numberGumballs)
        {
            count = numberGumballs;

            soldOutState    = new SoldOutState();
            noQuarterState  = new NoQuarterState(this);
            hasQuarterState = new HasQuarterState(this);
            soldState       = new SoldState(this);
            winnerState     = new WinnerState(this);

            if (count > 0)
            {
                state = noQuarterState;
            }
            else
            {
                state = soldOutState;
            }
        }