<?php
$robots = new Observerable();
class KillingRobot implements SplObserver
{
public function update(SplSubject $subject)
{
echo "kill all humans";
}
}
class WashingRobot implements SplObserver
{
public function update(SplSubject $subject)
{
echo "wash all humans";
}
}
$killing_robot = new KillingRobot();
$washing_robot = new WashingRobot();
$robots->addObserver($killing_robot);
$robots->addObserver($washing_robot);
$robots->notify();
?>
|