// Выдаем два шарика
        public void Dispense()
        {
            gumballMachine.ReleaseBall();

            if (gumballMachine.GetCount() == 0)
            {
                gumballMachine.SetState(gumballMachine.GetSoldOutState());
            }
            // Если в автомате есть второй шарик, освобождаем его
            else
            {
                Console.WriteLine("YOU'RE A WINNER! You got two gumballs for your quarter");
                gumballMachine.ReleaseBall();

                if (gumballMachine.GetCount() > 0)
                {
                    gumballMachine.SetState(gumballMachine.GetNoQuarterState());
                }
                else
                {
                    Console.WriteLine("Oops, out of gumballs!");
                    gumballMachine.SetState(gumballMachine.GetSoldOutState());
                }
            }
        }
Пример #2
0
        public void Dispense()
        {
            gumballMachine.ReleaseBall();

            if (gumballMachine.GetCount() > 0)
            {
                gumballMachine.SetState(gumballMachine.GetNoQuarterState());
            }
            else
            {
                Console.WriteLine("Oops, out of gumballs!");
                gumballMachine.SetState(gumballMachine.GetSoldOutState());
            }
        }