Esempio n. 1
0
    {
        return $this->currentState;
    }
    public function powerUp()
    {
        $this->currentState->powerUp();
    }
    public function powerDown()
    {
        $this->currentState->powerDown();
    }
    public function turnIntoVehicle()
    {
        $this->currentState->turnIntoVehicle();
    }
    public function turnIntoRobot()
    {
        $this->currentState->turnIntoRobot();
    }
}
$robot = new Robot();
echo "\n";
$robot->powerUp();
echo "\n";
$robot->turnIntoRobot();
echo "\n";
$robot->turnIntoRobot();
/* This one will just give me a message */
echo "\n";
$robot->turnIntoVehicle();
echo "\n";