Example #1
0
    }
}
class BookStarsOffCommand extends BookCommand
{
    function execute()
    {
        $this->bookCommandee->setStarsOff();
    }
}
echo tagins("html");
echo tagins("head");
echo tagins("/head");
echo tagins("body");
echo "BEGIN TESTING COMMAND PATTERN";
echo tagins("br") . tagins("br");
$book = new BookCommandee("Design Patterns", "Gamma, Helm, Johnson, and Vlissides");
echo "book after creation: ";
echo tagins("br");
echo $book->getAuthorAndTitle();
echo tagins("br") . tagins("br");
$starsOn = new BookStarsOnCommand($book);
callCommand($starsOn);
echo "book after stars on: ";
echo tagins("br");
echo $book->getAuthorAndTitle();
echo tagins("br") . tagins("br");
$starsOff = new BookStarsOffCommand($book);
callCommand($starsOff);
echo "book after stars off: ";
echo tagins("br");
echo $book->getAuthorAndTitle();
Example #2
0
{
    function execute()
    {
        $this->bookCommandee->setStarsOn();
    }
}
class BookStarsOffCommand extends BookCommand
{
    function execute()
    {
        $this->bookCommandee->setStarsOff();
    }
}
writeln('BEGIN TESTING COMMAND PATTERN');
writeln('');
$book = new BookCommandee('Design Patterns', 'Gamma, Helm, Johnson, and Vlissides');
writeln('book after creation: ');
writeln($book->getAuthorAndTitle());
writeln('');
$starsOn = new BookStarsOnCommand($book);
callCommand($starsOn);
writeln('book after stars on: ');
writeln($book->getAuthorAndTitle());
writeln('');
$starsOff = new BookStarsOffCommand($book);
callCommand($starsOff);
writeln('book after stars off: ');
writeln($book->getAuthorAndTitle());
writeln('');
writeln('END TESTING COMMAND PATTERN');
// the callCommand function demonstrates that a specified