<?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);

$purchase = array(
    $wm1,
    $wm2,
    $we1
);
$purDep   = new Department('Департамент закупок', $purchase);

echo $purDep->name;
echo "\n Сумма по зарплатам - " . $purDep->sumMoney();
echo "\n Количество выпитого кофе - " . $purDep->sumCofe();
echo "\n Количество страниц - " . $purDep->sumPage();