Modo de comando
interface Command
{
public function execute();
}
class Light
{
public function on()
{
echo "on";
}
}
class SimpleRemoteControl
{
private $slot = null;
public function __construct()
{
}
public function setCommand($command) {
$this->slot = $command;
}
public function buttonWasPressed()
{
$this->slot->execute();
}
}
class LightOnCommand implements Command
{
private $light = null;
public function __construct($light)
{
$this->light = $light;
}
public function execute()
{
$this->light->on();
// TODO: Implement execute() method.
}
}