<?php
abstract class Employee
{
public $salary;
public $pages;
public $cofee;
public $name;
function __construct($quantity, $rank)
{
$this->quantity = $quantity;
$this->rank = $rank;
}
function getSalary()
{
$multiply = 1;
switch ($this->rank) {
case 2:
$multiply = 1.25;
break;
case 3:
$multiply = 1.50;
break;
}
$getSalary = $this->salary * $multiply * $this->quantity;
return $getSalary;
}
function getCofee()
{
$getCofee = $this->quantity * $this->cofee;
return $getCofee;
}
function getPages()
{
$getPages = $this->quantity * $this->pages;
return $getPages;
}
}
class Manager extends Employee
{
public $name = "Менеджер";
public $salary = 500;
public $cofee = 20;
public $pages = 200;
}
class Market extends Employee
{
public $name = "Маркетолог";
public $salary = 400;
public $cofee = 15;
public $pages = 150;
}
class Engineer extends Employee
{
public $name = "Инженер";
public $salary = 200;
public $cofee = 5;
public $pages = 50;
}
class Analyst extends Employee
{
public $name = "Аналитик";
public $salary = 800;
public $cofee = 50;
public $pages = 5;
}
class Department
{
public $workers;
public $costs;
public $totalCofee;
public $totalPages;
function __construct($name)
{
$this->name = $name;
return $this->name;
}
}
new Manager(9, 1),
new Manager(3, 2),
new Manager(2, 3),
new Market(2, 1),
'name' => 'закупок'
);
function createDepartment($data)
{
$department = new Department($data['name']);
foreach ($data as $key => $workers) {
continue;
}
$department->workers = $department->workers + $data[$key]->quantity;
$department->costs = $department->costs + $data[$key]->getSalary();
$department->totalCofee = $department->totalCofee + $data[$key]->getCofee();
$department->totalPages = $department->totalPages + $data[$key]->getPages();
}
echo "Департамент " . $department->name;
echo " \n Работников {$department->workers}";
echo " \n Расходы {$department->costs}";
echo "\n Кофе {$department->totalCofee}";
echo " \n Страниц $department->totalPages";
}
createDepartment($department1);
PD9waHAKCmFic3RyYWN0IGNsYXNzIEVtcGxveWVlCnsKICAgIAogICAgcHVibGljICRzYWxhcnk7CiAgICBwdWJsaWMgJHBhZ2VzOwogICAgcHVibGljICRjb2ZlZTsKICAgIHB1YmxpYyAkbmFtZTsKICAgIAogICAgCiAgICBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkcXVhbnRpdHksICRyYW5rKQogICAgewogICAgICAgIAogICAgICAgICR0aGlzLT5xdWFudGl0eSA9ICRxdWFudGl0eTsKICAgICAgICAkdGhpcy0+cmFuayAgICAgPSAkcmFuazsKICAgIH0KICAgIAogICAgZnVuY3Rpb24gZ2V0U2FsYXJ5KCkKICAgIHsKICAgICAgICAkbXVsdGlwbHkgPSAxOwogICAgICAgIHN3aXRjaCAoJHRoaXMtPnJhbmspIHsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgJG11bHRpcGx5ID0gMS4yNTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICAkbXVsdGlwbHkgPSAxLjUwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgICRnZXRTYWxhcnkgPSAkdGhpcy0+c2FsYXJ5ICogJG11bHRpcGx5ICogJHRoaXMtPnF1YW50aXR5OwogICAgICAgIHJldHVybiAkZ2V0U2FsYXJ5OwogICAgfQogICAgCiAgICBmdW5jdGlvbiBnZXRDb2ZlZSgpCiAgICB7CiAgICAgICAgJGdldENvZmVlID0gJHRoaXMtPnF1YW50aXR5ICogJHRoaXMtPmNvZmVlOwogICAgICAgIHJldHVybiAkZ2V0Q29mZWU7CiAgICB9CiAgICAKICAgIGZ1bmN0aW9uIGdldFBhZ2VzKCkKICAgIHsKICAgICAgICAkZ2V0UGFnZXMgPSAkdGhpcy0+cXVhbnRpdHkgKiAkdGhpcy0+cGFnZXM7CiAgICAgICAgcmV0dXJuICRnZXRQYWdlczsKICAgIH0KICAgIAp9CgpjbGFzcyBNYW5hZ2VyIGV4dGVuZHMgRW1wbG95ZWUKewogICAgcHVibGljICRuYW1lID0gItCc0LXQvdC10LTQttC10YAiOwogICAgcHVibGljICRzYWxhcnkgPSA1MDA7CiAgICBwdWJsaWMgJGNvZmVlID0gMjA7CiAgICBwdWJsaWMgJHBhZ2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