<?php
abstract class Employee
{
public $salary;
public $pages;
public $cofee;
public $name;
function __construct($rank)
{
$this->rank = $rank;
}
function getSalary()
{
$multiply = 1;
switch ($this->rank) {
case 2:
$multiply = 1.25;
break;
case 3:
$multiply = 1.50;
break;
}
return $this->salary * $multiply;
}
}
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
{
function workers($data)
{
}
function cofee($data)
{
$cofee = 0;
foreach ($data as $key => $worker) {
if ($key === 'name') {
continue;
}
$cofee += $worker->cofee;
}
return $cofee;
}
function costs($data)
{
$costs = 0;
foreach ($data as $key => $worker) {
if ($key === 'name') {
continue;
}
$costs += $worker->getSalary();
}
return $costs;
}
function pages($data)
{
$pages = 0;
foreach ($data as $key => $worker) {
if ($key === 'name') {
continue;
}
$pages += $worker->pages;
}
return $pages;
}
function __construct($name)
{
$this->name = $name;
return $this->name;
}
}
'name' => 'продаж'
);
for ($i = 0; $i < 9; $i++) {
$department1[] = new Manager(1);
}
for ($i = 0; $i < 3; $i++) {
$department1[] = new Manager(2);
}
for ($i = 0; $i < 2; $i++) {
$department1[] = new Manager(3);
}
for ($i = 0; $i < 2; $i++) {
$department1[] = new Market(1);
}
function createDepartment($data)
{
$department = new Department($data['name']);
echo "Департамент " . $department->name;
echo " \n Работников {$department->workers($data)}";
echo " \n Расходы {$department->costs($data)}";
echo " \n Кофе {$department->cofee($data)}";
echo " \n Страницы {$department->pages($data)}";
}
createDepartment($department1);