$this->title = $title_in; } function getAuthor() { return $this->author; } function getTitle() { return $this->title; } function getAuthorAndTitle() { return $this->getTitle() . ' by ' . $this->getAuthor(); } } //testProxy.php include_once 'ProxyBookList.class.php'; include_once 'Book.class.php'; $proxyBookList = new ProxyBookList(); $inBook = new Book('The life of Alice in Wonderland', 'Someone'); $proxyBookList->addBook($inBook); echo 'Total number of books added:' . $proxyBookList->getBookCount() . '<br/>'; $outBook = $proxyBookList->getBook(1); echo 'Displaying books(s) details:' . $outBook->getAuthorAndTitle() . '<br/>'; $proxyBookList->removeBook($outBook); echo 'Total number of books available after removal operation:' . $proxyBookList->getBookCount() . '<br/>'; /* output Total number of books added:1 Displaying books(s) details:The life of Alice in Wonderland by Someone Total number of books available after removal operation:0 */
} function getTitle() { return $this->title; } function getAuthorAndTitle() { return $this->getTitle() . ' by ' . $this->getAuthor(); } } writeln('BEGIN TESTING PROXY PATTERN'); writeln(''); $proxyBookList = new ProxyBookList(); $inBook = new Book('PHP for Cats', 'Larry Truett'); $proxyBookList->addBook($inBook); writeln('test 1 - show the book count after a book is added'); writeln($proxyBookList->getBookCount()); writeln(''); writeln('test 2 - show the book'); $outBook = $proxyBookList->getBook(1); writeln($outBook->getAuthorAndTitle()); writeln(''); $proxyBookList->removeBook($outBook); writeln('test 3 - show the book count after a book is removed'); writeln($proxyBookList->getBookCount()); writeln(''); writeln('END TESTING PROXY PATTERN'); function writeln($line_in) { echo $line_in . "<br/>"; }
function getAuthor() { return $this->author; } function getTitle() { return $this->title; } function getAuthorAndTitle() { return $this->getTitle() . ' by ' . $this->getAuthor(); } } define('BR', '<' . 'BR' . '>'); echo 'BEGIN TESTING PROXY PATTERN' . BR; echo BR; $proxyBookList = new ProxyBookList(); $inBook = new Book('PHP for Cats', 'Larry Truett'); $proxyBookList->addBook($inBook); echo 'test 1 - show the book count after a book is added' . BR; echo $proxyBookList->getBookCount(); echo BR . BR; echo 'test 2 - show the book' . BR; $outBook = $proxyBookList->getBook(1); echo $outBook->getAuthorAndTitle(); echo BR . BR; $proxyBookList->removeBook($outBook); echo 'test 3 - show the book count after a book is removed' . BR; echo $proxyBookList->getBookCount(); echo BR . BR; echo 'END TESTING PROXY PATTERN' . BR;