예제 #1
0
        public void Dispense()
        {
            Console.WriteLine("SS: Dispensing");

            _gumballMachine.ReleaseBall();

            if (_gumballMachine.Count > 0)
            {
                _gumballMachine.SetState(_gumballMachine.NoQuarterState);
            }
            else
            {
                _gumballMachine.SetState(_gumballMachine.SoldOutState);
            }
        }
예제 #2
0
        public void Dispense()
        {
            Console.WriteLine("WS: WINNER!");

            _gumballMachine.ReleaseBall();

            if (_gumballMachine.Count == 0)
            {
                _gumballMachine.SetState(_gumballMachine.SoldOutState);
            }
            else
            {
                _gumballMachine.ReleaseBall();

                if (_gumballMachine.Count == 0)
                {
                    _gumballMachine.SetState(_gumballMachine.SoldOutState);
                }
                else
                {
                    _gumballMachine.SetState(_gumballMachine.NoQuarterState);
                }
            }
        }
 public void EjectQuarter()
 {
     Console.WriteLine("HQS: Quarter returned...");
     _gumballMachine.SetState(_gumballMachine.NoQuarterState);
 }
예제 #4
0
 public void InsertQuarter()
 {
     Console.WriteLine("NQS: Thank you for inserting a quarter!");
     _gumballMachine.SetState(_gumballMachine.HasQuarterState);
 }