public void dispense()
 {
     if (machine.getGumballsCount() > 0)
     {
         System.Console.WriteLine("Dispensing one gumball.");
         machine.removeGumball();
         if (machine.getGumballsCount() == 0)
         {
             machine.setState("SoldOut");
         }
         else
         {
             machine.setState("NoQuarter");
         }
     }
     else
     {
         System.Console.WriteLine("Out of gumballs.");
         machine.setState("HasQuarter");
         machine.ejectQuarter();
         machine.setState("SoldOut");
     }
 }
Beispiel #2
0
 public void insertQuarter()
 {
     System.Console.WriteLine("You inserted a quarter!");
     machine.setState("HasQuarter");
 }
Beispiel #3
0
 public void ejectQuarter()
 {
     System.Console.WriteLine("Ejected quarter");
     machine.setState("NoQuarter");
 }
 public void refill()
 {
     System.Console.WriteLine("Refilling gumball machine.");
     machine.addGumballs();
     machine.setState("NoQuarter");
 }