public void dispense()
 {
     gumballMachine.releaseBall();
     if (gumballMachine.getCount() > 0)
     {
         gumballMachine.setState(gumballMachine.getNoQuarterState());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs!");
         gumballMachine.setState(gumballMachine.getSoldOutState());
     }
 }
Exemple #2
0
        public void dispense()
        {
            Console.WriteLine("YOU'RE A WINNER! You get two gumballs for your quarter");
            gumballMachine.releaseBall();

            if (gumballMachine.getCount() == 0)
            {
                Console.WriteLine("Oops, out of gumballs!");
                gumballMachine.setState(gumballMachine.getSoldOutState());
            }
            else
            {
                gumballMachine.releaseBall();
                if (gumballMachine.getCount() > 0)
                {
                    gumballMachine.setState(gumballMachine.getNoQuarterState());
                }
                else
                {
                    Console.WriteLine("Oops, out of gumballs!");
                    gumballMachine.setState(gumballMachine.getSoldOutState());
                }
            }
        }
 public void insertQuarter()
 {
     Console.WriteLine("You inserted a quarter");
     gumballMachine.setState(gumballMachine.getHasQuarterState());
 }
 public void ejectQuarter()
 {
     Console.WriteLine("Quarter returned");
     gumballMachine.setState(gumballMachine.getNoQuarterState());
 }