Пример #1
0
<?php

include_once 'IFighter.class.php';
include_once 'NightsWatch.class.php';
class Varys implements IFighter
{
    public function pretendToFight()
    {
        print "* finds someone to fight for him *" . PHP_EOL;
    }
}
$varys = new Varys();
$nw = new NightsWatch();
$nw->recruit($varys);
$nw->fight();
?>

Пример #2
0
    public function isABastard()
    {
        return True;
    }
}
class MaesterAemon
{
    public function sendRavens()
    {
        print "* sends a raven carrying an important message *" . PHP_EOL;
    }
}
class SamwellTarly implements IFighter
{
    public function fight()
    {
        print "* flees, finds a girl, grows a spine, and defends her to the bitter end *" . PHP_EOL;
    }
    public function makeHisFatherProud()
    {
        return False;
    }
}
$jon = new JonSnow();
$aemon = new MaesterAemon();
$sam = new SamwellTarly();
$nw = new NightsWatch();
$nw->recruit($jon);
$nw->recruit($aemon);
$nw->recruit($sam);
$nw->fight();