Собственно упрощенная модель. Жена принесла коньяк - начинаю тестировать
<?php
class Man
{
protected $fakeVar;
public function go()
{
/* do it */
}
public function sleep()
{
/* do it */
}
public function eat()
{
/* do it */
}
public function crap()
{
/* do it */
}
public function play($time)
{
/* do it */
}
public function isSleeping() { /* do it */ return $this->fakeVar; }
public function isEating() { /* do it */ return $this->fakeVar; }
public function isCraping() { /* do it */ return $this->fakeVar; }
public function isBusy() { /* do it */ return $this->fakeVar; }
}
interface Drinkable
{
public function drink($volume);
}
class PhpDeveloper extends Man
{
public function code($time)
{
/* do it */
}
public function study($time)
{
/* do it */
}
public function isCoding() { /* do it */ return $this->fakeVar; }
public function isStudying() { /* do it */ return $this->fakeVar; }
public function isBusy() { /* do it */ return $this->fakeVar; }
public function go()
{
parent::go();
/* do it */
}
}
class WhiskeyDeveloper extends PhpDeveloper implements Drinkable
{
const THRESHOLD = 0.01;
const BALMERPEAK = 0.13;
private $alcogolConcentration;
public function drink($volume)
{
/* do it */
}
public function detectConcentration()
{
/* do it */
return $this->alcogolConcentration;
}
public function go()
{
parent::go();
if ($this->isBusy())
return;
if ($this->detectConcentration() < self::BALMERPEAK - self::THRESHOLD)
{
$this->drink(0.05);
$this->study(10);
return;
}
if ($this->detectConcentration() > self::BALMERPEAK + self::THRESHOLD*10)
{
$this->sleep();
return;
}
if ($this->detectConcentration() > self::BALMERPEAK + self::THRESHOLD)
{
$this->play(10);
return;
}
$this->code(10);
}
}