<?php
class WORKER
{
public $rank;
public $boss;
function __construct($rank, $boss)
{
$this->rank = $rank;
$this->boss = $boss;
}
function money()
{
if ($this->rank == 1) {
$money = $this->money;
}
if ($this->rank == 2) {
$money = $this->money * 1.25;
}
if ($this->rank == 3) {
$money = $this->money * 1.5;
}
if ($this->boss) {
return $money * 1.5;
} else
return $money;
}
function cofe()
{
if ($this->boss) {
$cofe = 2 * $this->cofe;
return $cofe;
} else {
return $this->cofe;
}
}
function page()
{
if ($this->boss) {
$page = 0;
return $page;
} else {
return $this->page;
}
}
}
class MANAGER extends WORKER
{
public $money = 400;
public $cofe = 15;
public $page = 150;
}
class ENGINEER extends WORKER
{
public $money = 200;
public $cofe = 10;
public $page = 100;
}
class Department
{
public $name;
public $workers = array(); function __construct($name, $workers)
{
$this->name = $name;
$this->workers = $workers;
}
function sumMoney()
{
$sumMoney="";
foreach ($this->workers as $worker) {
$sumMoney = $sumMoney + $worker->money();
}
return $sumMoney;
}
function sumCofe()
{
$sumCofe="";
foreach ($this->workers as $worker) {
$sumCofe = $sumCofe + $worker->cofe();
}
return $sumCofe;
}
function sumPage()
{
$sumPage="";
foreach ($this->workers as $worker) {
$sumPage = $sumPage + $worker->page();
}
return $sumPage;
}
}
$wm1 = new MANAGER(2, true);
$wm2 = new MANAGER(1, false);
$we1 = new ENGINEER(2, false);
$wm1,
$wm2,
$we1
);
$purDep = new Department('Департамент закупок', $purchase);
echo $purDep->name;
echo "\n Сумма по зарплатам - " . $purDep->sumMoney();
echo "\n Количество выпитого кофе - " . $purDep->sumCofe();
echo "\n Количество страниц - " . $purDep->sumPage();
PD9waHAKY2xhc3MgV09SS0VSCnsKICAgIHB1YmxpYyAkcmFuazsKICAgIHB1YmxpYyAkYm9zczsKICAgIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRyYW5rLCAkYm9zcykKICAgIHsKICAgICAgICAkdGhpcy0+cmFuayA9ICRyYW5rOwogICAgICAgICR0aGlzLT5ib3NzID0gJGJvc3M7CiAgICB9CiAgICBmdW5jdGlvbiBtb25leSgpCiAgICB7CiAgICAgICAgaWYgKCR0aGlzLT5yYW5rID09IDEpIHsKICAgICAgICAgICAgJG1vbmV5ID0gJHRoaXMtPm1vbmV5OwogICAgICAgIH0KICAgICAgICBpZiAoJHRoaXMtPnJhbmsgPT0gMikgewogICAgICAgICAgICAkbW9uZXkgPSAkdGhpcy0+bW9uZXkgKiAxLjI1OwogICAgICAgIH0KICAgICAgICBpZiAoJHRoaXMtPnJhbmsgPT0gMykgewogICAgICAgICAgICAkbW9uZXkgPSAkdGhpcy0+bW9uZXkgKiAxLjU7CiAgICAgICAgfQogICAgICAgIGlmICgkdGhpcy0+Ym9zcykgewogICAgICAgICAgICByZXR1cm4gJG1vbmV5ICogMS41OwogICAgICAgIH0gZWxzZQogICAgICAgICAgICByZXR1cm4gJG1vbmV5OwogICAgfQogICAgZnVuY3Rpb24gY29mZSgpCiAgICB7CiAgICAgICAgaWYgKCR0aGlzLT5ib3NzKSB7CiAgICAgICAgICAgICRjb2ZlID0gMiAqICR0aGlzLT5jb2ZlOwogICAgICAgICAgICByZXR1cm4gJGNvZmU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuICR0aGlzLT5jb2ZlOwogICAgICAgIH0KICAgIH0KICAgIGZ1bmN0aW9uIHBhZ2UoKQogICAgewogICAgICAgIGlmICgkdGhpcy0+Ym9zcykgewogICAgICAgICAgICAkcGFnZSA9IDA7CiAgICAgICAgICAgIHJldHVybiAkcGFnZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gJHRoaXMtPnBhZ2U7CiAgICAgICAgfQogICAgfQp9CmNsYXNzIE1BTkFHRVIgZXh0ZW5kcyBXT1JLRVIKewogICAgcHVibGljICRtb25leSA9IDQwMDsKICAgIHB1YmxpYyAkY29mZSA9IDE1OwogICAgcHVibGljICRwYWdlID0gMTUwOwp9CmNsYXNzIEVOR0lORUVSIGV4dGVuZHMgV09SS0VSCnsKICAgIHB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