{ $this->btd->title = Str_replace(" ", "*", $this->btd->title); } } echo tagins("html"); echo tagins("head"); echo tagins("/head"); echo tagins("body"); echo "BEGIN TESTING DECORATOR PATTERN"; echo tagins("br") . tagins("br"); $patternBook = new Book("Gamma, Helm, Johnson, and Vlissides", "Design Patterns"); $decorator = new BookTitleDecorator($patternBook); $starDecorator = new BookTitleStarDecorator($decorator); $exclaimDecorator = new BookTitleExclaimDecorator($decorator); echo "showing title : " . tagins("br"); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after two exclaims added : " . tagins("br"); $exclaimDecorator->exclaimTitle(); $exclaimDecorator->exclaimTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after star added : " . tagins("br"); $starDecorator->starTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo "showing title after reset: " . tagins("br"); echo $decorator->resetTitle(); echo $decorator->showTitle(); echo tagins("br") . tagins("br"); echo tagins("br");
{ $this->btd = $btd_in; } function starTitle() { $this->btd->title = Str_replace(" ", "*", $this->btd->title); } } writeln('BEGIN TESTING DECORATOR PATTERN'); writeln(''); $patternBook = new Book('Gamma, Helm, Johnson, and Vlissides', 'Design Patterns'); $decorator = new BookTitleDecorator($patternBook); $starDecorator = new BookTitleStarDecorator($decorator); $exclaimDecorator = new BookTitleExclaimDecorator($decorator); writeln('showing title : '); writeln($decorator->showTitle()); writeln(''); writeln('showing title after two exclaims added : '); $exclaimDecorator->exclaimTitle(); $exclaimDecorator->exclaimTitle(); writeln($decorator->showTitle()); writeln(''); writeln('showing title after star added : '); $starDecorator->starTitle(); writeln($decorator->showTitle()); writeln(''); writeln('showing title after reset: '); writeln($decorator->resetTitle()); writeln($decorator->showTitle()); writeln(''); writeln('END TESTING DECORATOR PATTERN');