コード例 #1
0
        public void Dispense()
        {
            Console.WriteLine("A gumball comes rolling out the slot ");

            _gumballMachine.ReleaseBall();

            if (_gumballMachine.Count.Equals(0))
            {
                Console.WriteLine("Out of gumballs");

                _gumballMachine.SetState(_gumballMachine.SoldOutState);
            }

            else
            {
                _gumballMachine.SetState(_gumballMachine.NoQuarterState);
            }
        }
コード例 #2
0
        public void Dispense()
        {
            Console.WriteLine("You're a winner! You get two gumballs for your quarter");

            _gumballMachine.ReleaseBall();

            _gumballMachine.ReleaseBall();

            if (_gumballMachine.Count.Equals(0))
            {
                Console.WriteLine("Out of gumballs");

                _gumballMachine.SetState(_gumballMachine.SoldOutState);
            }

            else
            {
                _gumballMachine.SetState(_gumballMachine.NoQuarterState);
            }
        }
コード例 #3
0
        public void EjectQuarter()
        {
            Console.WriteLine("Quarter returned");

            _gumballMachine.SetState(_gumballMachine.NoQuarterState);
        }
コード例 #4
0
        public void InsertQuarter()
        {
            Console.WriteLine("You inserted a quarter.");

            _gumballMachine.SetState(_gumballMachine.HasQuarterState);
        }