<?php
// your code goes here
/*
Департамент закупок: 9×ме1, 3×ме2, 2×ме3, 2×ма1 + руководитель департамента ме2
Департамент продаж: 12×ме1, 6×ма1, 3×ан1, 2×ан2 + руководитель ма2
Департамент рекламы: 15×ма1, 10×ма2, 8×ме1, 2×ин1 + руководитель ма3
Департамент логистики: 13×ме1, 5×ме2, 5×ин1 + руководитель ме1
*/
class Employee {
protected $salary;
protected $coffee;
protected $reports;
protected $rank;
protected $isHead;
public function __construct($rank, $isHead) {
$this->rank = $rank;
$this->isHead = $isHead;
$this->setSalary($this->salary);
$this->setCoffee($this->coffee);
$this->setReports($this->reports);
}
public function getSalary() {
return $this->salary;
}
public function setSalary($salary) {
switch ($this->rank) {
case 1:
$this->salary = $salary;
break;
case 2:
$this->salary = $salary * 1.25;
break;
case 3:
$this->salary = $salary * 1.5;
break;
default:
$this->salary = "Ошибка";
break;
}
if ($this->isHead) {
$this->salary *= 2;
}
}
public function getCoffee() {
return $this->coffee;
}
public function setCoffee($coffee) {
$this->coffee = $coffee;
if ($this->isHead) {
$this->coffee *= 2;
}
}
public function getReports() {
return $this->reports;
}
public function setReports($reports) {
if ($this->isHead) {
$this->reports = 0;
} else {
$this->reports = $reports;
}
}
public function getRank()
{
return $this->rank;
}
public function setRank($rank)
{
$this->rank = $rank;
}
public function getIsHead()
{
return $this->isHead;
}
public function setIsHead($isHead)
{
$this->isHead = $isHead;
}
}
class Manager extends Employee {
public $name = "manager";
protected $salary = 500;
protected $coffee = 20;
protected $reports = 200;
}
class Marketer extends Employee {
public $name = "marketer";
protected $salary = 400;
protected $coffee = 15;
protected $reports = 150;
}
class Engineer extends Employee {
protected $salary = 200;
protected $coffee = 5;
protected $reports = 50;
}
class Analyst extends Employee {
protected $salary = 800;
protected $coffee = 50;
protected $reports = 5;
}
class Department {
private $name;
private $employees;
public function __construct($name, $employees) {
$this->name = $name;
$this->employees = $employees;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
public function getAllEmployees() {
return count($this->employees); }
public function getAllSalary() {
$allSalary = 0;
foreach ($this->employees as $employee) {
$allSalary += $employee->getSalary();
}
return $allSalary;
}
public function getAllCoffee() {
$allCoffee = 0;
foreach ($this->employees as $employee) {
$allCoffee += $employee->getCoffee();
}
return $allCoffee;
}
public function getAllReports() {
$allReports = 0;
foreach ($this->employees as $employee) {
$allReports += $employee->getReports();
}
return $allReports;
}
}
function createManagers($quantity, $rank, $isHead) {
for ($i = 0; $i < $quantity; $i++) {
array_push($employees, new Manager
($rank, $isHead)); }
return $employees;
}
function createMarketers($quantity, $rank, $isHead) {
for ($i = 0; $i < $quantity; $i++) {
array_push($employees, new Marketer
($rank, $isHead)); }
return $employees;
}
function createEngineers($quantity, $rank, $isHead) {
for ($i = 0; $i < $quantity; $i++) {
array_push($employees, new Engineer
($rank, $isHead)); }
return $employees;
}
function createAnalysts($quantity, $rank, $isHead) {
for ($i = 0; $i < $quantity; $i++) {
array_push($employees, new Analyst
($rank, $isHead)); }
return $employees;
}
function padRight($string, $length) {
//echo strlen($string) . $length;
for ($i = 0; $i < $spacesCount; $i++) {
$string .= " ";
}
return $string;
}
function padLeft($string, $length) {
$modString = "";
for ($i = 0; $i < $spacesCount; $i++) {
$modString .= " ";
}
$modString .= $string;
return $modString;
}
function outputString($str1, $str2, $str3, $str4, $str5, $str6) {
$col = 11;
echo padRight($str1, $col);
echo padLeft($str2, $col);
echo padLeft($str3, $col);
echo padLeft($str4, $col);
echo padLeft($str5, $col);
echo padLeft($str6, $col) . "\n";
}
$totalEmployees = 0;
$totalSalary = 0;
$totalCoffee = 0;
$totalReports = 0;
$totalConsumption = 0;
$countDepartments = 0;
outputString("Департамент", "сотр.", "тугр.", "кофе", "стр.", "тугр./стр.");
for ($i = 0; $i < 70; $i++) {
echo "-";
}
echo "\n";
$employees = array_merge($employees, createManagers
(9, 1, false), createManagers
(3, 2, false), createManagers(2, 3, false), createMarketers(2, 1, false), createManagers(1, 2, true));
$purchases = new Department("Закупок", $employees);
$countDepartments++;
$employees = array_merge($employees, createManagers
(12, 1, false), createMarketers
(6, 1, false), createAnalysts(3, 1, false), createAnalysts(2, 2, false), createMarketers(1, 2, true));
$sales = new Department("Продаж", $employees);
$countDepartments++;
$employees = array_merge($employees, createMarketers
(15, 1, false), createMarketers
(10, 2, false), createManagers(8, 1, false), createEngineers(2, 1, false), createMarketers(1, 3, true));
$ad = new Department("Рекламы", $employees);
$countDepartments++;
$employees = array_merge($employees, createManagers
(13, 1, false), createManagers
(5, 2, false), createEngineers(5, 1, false), createManagers(1, 1, true));
$logistics = new Department("Логистики", $employees);
$countDepartments++;
foreach ($departments as $department) {
$employeesCount = $department->getAllEmployees();
$totalEmployees += $employeesCount;
$salary = $department->getAllSalary();
$totalSalary += $salary;
$coffee = $department->getAllCoffee();
$totalCoffee += $coffee;
$reports = $department->getAllReports();
$totalReports += $reports;
$consumption = round($salary / $reports, 2); $totalConsumption += $consumption;
outputString($department->getName(), $employeesCount, $salary, $coffee, $reports, $consumption);
}
echo "\n";
outputString("Среднее", $totalEmployees / $countDepartments, $totalSalary / $countDepartments, $totalCoffee / $countDepartments,
$totalReports / $countDepartments, $totalConsumption / $countDepartments);
outputString("Всего", $totalEmployees, $totalSalary, $totalCoffee, $totalReports, $totalConsumption);
PD9waHAKLy8geW91ciBjb2RlIGdvZXMgaGVyZQoKLyoK0JTQtdC/0LDRgNGC0LDQvNC10L3RgiDQt9Cw0LrRg9C/0L7QujogOcOX0LzQtTEsIDPDl9C80LUyLCAyw5fQvNC1MywgMsOX0LzQsDEgKyDRgNGD0LrQvtCy0L7QtNC40YLQtdC70Ywg0LTQtdC/0LDRgNGC0LDQvNC10L3RgtCwINC80LUyCtCU0LXQv9Cw0YDRgtCw0LzQtdC90YIg0L/RgNC+0LTQsNC2OiAxMsOX0LzQtTEsIDbDl9C80LAxLCAzw5fQsNC9MSwgMsOX0LDQvTIgKyDRgNGD0LrQvtCy0L7QtNC40YLQtdC70Ywg0LzQsDIK0JTQtdC/0LDRgNGC0LDQvNC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YWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICR0aGlzLT5zYWxhcnkgPSAkc2FsYXJ5ICogMS4yNTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICAkdGhpcy0+c2FsYXJ5ID0gJHNhbGFyeSAqIDEuNTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgJHRoaXMtPnNhbGFyeSA9ICLQntGI0LjQsdC60LAiOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICgkdGhpcy0+aXNIZWFkKSB7CiAgICAgICAgICAgICR0aGlzLT5zYWxhcnkgKj0gMjsKICAgICAgICB9CiAgICB9CiAgICBwdWJsaWMgZnVuY3Rpb24gZ2V0Q29mZmVlKCkgewogICAgICAgIHJldHVybiAkdGhpcy0+Y29mZmVlOwogICAgfQogICAgcHVibGljIGZ1bmN0aW9uIHNldENvZmZlZSgkY29mZmVlKSB7CiAgICAgICAgJHRoaXMtPmNvZmZlZSA9ICRjb2ZmZWU7CiAgICAgICAgaWYgKCR0aGlzLT5pc0hlYWQpIHsKICAgICAgICAgICAgJHRoaXMtPmNvZmZlZSAqPSAyOwogICAgICAgIH0KICAgIH0KICAgIHB1YmxpYyBmdW5jdGlvbiBnZXRSZXBvcnRzKCkgewogICAgICAgIHJldHVybiAkdGhpcy0+cmVwb3J0czsKICAgIH0KICAgIHB1YmxpYyBmdW5jdGlvbiBzZXRSZXBvcnRzKCRyZXBvcnRzKSB7CiAgICAgICAgaWYgKCR0aGlzLT5pc0hlYWQpIHsKICAgICAgICAgICAgJHRoaXMtPnJlcG9ydHMgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICR0aGlzLT5yZXBvcnRzID0gJHJlcG9ydHM7CiAgICAgICAgfQogICAgfQogICAgcHVibGljIGZ1bmN0aW9uIGdldF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