Example #1
0
    {
        return $this->author;
    }
    function getTitle()
    {
        return $this->title;
    }
    function getAuthorAndTitle()
    {
        return $this->getTitle() . ' by ' . $this->getAuthor();
    }
}
writeln('BEGIN TESTING STATE PATTERN');
writeln('');
$book = new Book('PHP for Cats', 'Larry Truett');
$context = new bookContext($book);
writeln('test 1 - show name');
writeln($context->getBookTitle());
writeln('');
writeln('test 2 - show name');
writeln($context->getBookTitle());
writeln('');
writeln('test 3 - show name');
writeln($context->getBookTitle());
writeln('');
writeln('test 4 - show name');
writeln($context->getBookTitle());
writeln('');
writeln('END TESTING STATE PATTERN');
function writeln($line_in)
{
Example #2
0
    function getAuthor()
    {
        return $this->author;
    }
    function getTitle()
    {
        return $this->title;
    }
    function getAuthorAndTitle()
    {
        return $this->getTitle() . ' by ' . $this->getAuthor();
    }
}
define('BR', '<' . 'BR' . '>');
echo 'BEGIN TESTING STATE PATTERN' . BR;
echo BR;
$book = new Book('PHP for Cats', 'Larry Truett');
$context = new bookContext($book);
echo 'test 1 - show name' . BR;
echo $context->getBookTitle();
echo BR . BR;
echo 'test 2 - show name' . BR;
echo $context->getBookTitle();
echo BR . BR;
echo 'test 3 - show name' . BR;
echo $context->getBookTitle();
echo BR . BR;
echo 'test 4 - show name' . BR;
echo $context->getBookTitle();
echo BR . BR;
echo 'END TESTING STATE PATTERN' . BR;