コード例 #1
0
    {
        return Str_replace(" ", "*", $author_in);
    }
    function showTitle($title_in)
    {
        return Str_replace(" ", "*", $title_in);
    }
}
writeln('BEGIN TESTING BRIDGE PATTERN');
writeln('');
writeln('test 1 - author title with caps');
$book = new BridgeBookAuthorTitle('Larry Truett', 'PHP for Cats', 'CAPS');
writeln($book->showAuthorTitle());
writeln('');
writeln('test 2 - author title with stars');
$book = new BridgeBookAuthorTitle('Larry Truett', 'PHP for Cats', 'STARS');
writeln($book->showAuthorTitle());
writeln('');
writeln('test 3 - title author with caps');
$book = new BridgeBookTitleAuthor('Larry Truett', 'PHP for Cats', 'CAPS');
writeln($book->showTitleAuthor());
writeln('');
writeln('test 4 - title author with stars');
$book = new BridgeBookTitleAuthor('Larry Truett', 'PHP for Cats', 'STARS');
writeln($book->showTitleAuthor());
writeln('');
writeln('END TESTING BRIDGE PATTERN');
function writeln($line_in)
{
    echo $line_in . "<br/>";
}
コード例 #2
0
ファイル: bridge.php プロジェクト: sKudryashov/oop_patterns
}
class BridgeBookStarsImp extends BridgeBookImp
{
    function showAuthor($author_in)
    {
        return Str_replace(" ", "*", $author_in);
    }
    function showTitle($title_in)
    {
        return Str_replace(" ", "*", $title_in);
    }
}
define('BR', '<' . 'BR' . '>');
echo 'BEGIN TESTING BRIDGE PATTERN' . BR;
echo BR;
echo 'test 1 - author title with caps' . BR;
$book = new BridgeBookAuthorTitle('Larry Truett', 'PHP for Cats', 'CAPS');
echo $book->showAuthorTitle();
echo BR . BR;
echo 'test 2 - author title with stars' . BR;
$book = new BridgeBookAuthorTitle('Larry Truett', 'PHP for Cats', 'STARS');
echo $book->showAuthorTitle();
echo BR . BR;
echo 'test 3 - title author with caps' . BR;
$book = new BridgeBookTitleAuthor('Larry Truett', 'PHP for Cats', 'CAPS');
echo $book->showTitleAuthor();
echo BR . BR;
echo 'test 4 - title author with stars' . BR;
$book = new BridgeBookTitleAuthor('Larry Truett', 'PHP for Cats', 'STARS');
echo $book->showTitleAuthor();
echo BR . BR;