Can someone please tell me which design pattern is used in the code bellow? ``` class UnixText { function write($txt){echo $txt;} function lf() {echo "\n";}
}
class MSWindowsText
{
function write($txt){echo $txt;}
function crlf() {echo "\r\n";}
}
interface Writer
{
function write($txt);
function newLine();
}
class UnixWriter implements Writer{
private $target;
public function __construct($unixText){$this->target=$unixText; }
function write($txt){$this->target->write($txt);}
function newLine(){$this->target->lf();}
}
class MSWindowsWriter implements Writer{
private $target;
public function __construct($winText){$this->target=$winText; }
function write($txt){$this->target->write($txt);}
function newLine(){$this->target->crlf();}
}
```
Aucun commentaire:
Enregistrer un commentaire