public function turnCrank()
 {
     println("You turned...");
     $winner = rand(0, 9);
     if ($winner == 0 && $this->gumballMachine->getCount() > 1) {
         $this->gumballMachine->setState($this->gumballMachine->getWinnerState());
     } else {
         $this->gumballMachine->setState($this->gumballMachine->getSoldState());
     }
 }
 public function dispense()
 {
     $this->gumballMachine->releaseBall();
     if ($this->gumballMachine->getCount() > 0) {
         $this->gumballMachine->setState($this->gumballMachine->getNoQuarterState());
     } else {
         println("Oops, out of gumballs!");
         $this->gumballMachine->setState($this->gumballMachine->getSoldOutState());
     }
 }
 public function dispense()
 {
     println("YOU'RE A WINNER! You get two gumballs for your quarter");
     $this->gumballMachine->releaseBall();
     if ($this->gumballMachine->getCount() == 0) {
         $this->gumballMachine->setState($this->gumballMachine->getSoldOutState());
     } else {
         $this->gumballMachine->releaseBall();
         if ($this->gumballMachine->getCount() > 0) {
             $this->gumballMachine->setState($this->gumballMachine->getNoQuarterState());
         } else {
             println("Oops, out of gumballs!");
             $this->gumballMachine->setState($this->gumballMachine->getSoldOutState());
         }
     }
 }
 public function report()
 {
     println("Gumball Machine: " . $this->machine->getLocation());
     println("Current inventory: " . $this->machine->getCount() . " gumballs");
     println("Current state: " . $this->machine->getState());
 }