Esempio n. 1
0
        public GumballMachine(int count)
        {
            NoQuarterState  = new NoQuarterState(this);
            HasQuarterState = new HasQuarterState(this);
            SoldState       = new SoldState(this);
            SoldOutState    = new SoldOutState(this);
            WinnerState     = new WinnerState(this);

            Count = count;
            if (Count > 0)
            {
                _state = NoQuarterState;
            }
            else
            {
                _state = SoldOutState;
            }
        }
Esempio n. 2
0
        public GumballMachine(string location, int count)
        {
            NoQuarterState  = new NoQuarterState(this);
            HasQuarterState = new HasQuarterState(this);
            SoldState       = new SoldState(this);
            SoldOutState    = new SoldOutState(this);
            WinnerState     = new WinnerState(this);

            Location = location;

            Count = count;
            if (Count > 0)
            {
                State = NoQuarterState;
            }
            else
            {
                State = SoldOutState;
            }
        }