<?php class Company { public function add_departament($departament) { $this->departaments [] = $departament; } public function get_Count_Workers() { foreach ($this->departaments as $departament) { $count_workers += $departament->get_Sum_Workers(); } return $count_workers; } public function get_Average_Workers() { } public function get_Count_Salary() { foreach ($this->departaments as $departament) { $count_salary += $departament->get_Sum_Salary(); } return $count_salary; } public function get_Average_Salary() { } public function get_Count_Coffee() { foreach ($this->departaments as $departament) { $count_coffee += $departament->get_Sum_Coffee(); } return $count_coffee; } public function get_Average_Coffee() { } public function get_Count_Pages() { foreach ($this->departaments as $departament) { $count_pages += $departament->get_Sum_Pages(); } return $count_pages; } public function get_Average_Pages() { } public function get_Count_Salary_For_Page() { foreach ($this->departaments as $departament) { $count_salary_for_page += $departament->get_Salary_For_Page(); } return $count_salary_for_page; } public function get_Average_Salary_For_Page() { } public function print_Info() { $col2 = 12; $col3 = 15; foreach ($this->departaments as $departament) { echo padRight($departament->get_Departament_Name(), $col2); echo padLeft($departament->get_Sum_Workers(), $col2); echo padLeft($departament->get_Sum_Salary(), $col2); echo padLeft($departament->get_Sum_Coffee(), $col2); echo padLeft($departament->get_Sum_Pages(), $col2); echo padLeft($departament->get_Salary_For_Page(), $col3)."\n"; } } //Cократить в каждом департаменте 40% (округляя в большую сторону) инженеров, //преимущественно самого низкого ранга. Если инженер является боссом, вместо него //надо уволить другого инженера, не босса. public function Destruction_Workers($count_in_percent, $proffesion) { foreach ($this->departaments as $departament) { $count_workers = $departament->get_Workers_And_Destruction($count_in_percent, $proffesion); } } } class Departament { private $departament_name; public function __construct($name) { $this->set_Departament_Name($name); } public function get_Departament_Name() { return $this->departament_name; } public function set_Departament_Name($name) { $this->departament_name = $name; } public function add_Workers($count, $rank, $proffesion, $is_Head) { for ($i = 0; $i < $count; $i++) { $worker = new $proffesion($rank, $is_Head); $this->workers[] = $worker; } } public function get_Sum_Workers() { } public function get_Sum_Salary() { foreach ($this->workers as $worker) { $sum_salary = $sum_salary+$worker->get_Salary($worker); } return $sum_salary; } public function get_Sum_Coffee() { foreach ($this->workers as $worker) { $sum_coffee += $worker->get_Coffee($worker); } return $sum_coffee; } public function get_Sum_Pages() { foreach ($this->workers as $worker) { $sum_pages += $worker->get_Pages($worker); } return $sum_pages; } public function get_Salary_For_Page() { $salary = $this->get_Sum_Salary(); $pages = $this->get_Sum_Pages(); } public function get_Workers_And_Destruction($count_in_percent,$proffesion) { foreach ($this->workers as $worker) { if ($worker->get_Proffesion() == $proffesion) { $count_workers ++; } } $i = 0; foreach ($this->workers as $number => $worker) { if ($worker->get_Proffesion() == $proffesion && $worker->get_Rank() == '1' && $i < $sum_to_destroy && $worker->get_Is_Head() == false ) { $i++; } } foreach ($this->workers as $number => $worker) { if ($worker->get_Proffesion() == $proffesion && $worker->get_Rank() == '2' && $i < $sum_to_destroy && $worker->get_Is_Head() == false ) { $i++; } } foreach ($this->workers as $number => $worker) { if ($worker->get_Proffesion() == $proffesion && $worker->get_Rank() == '3' && $i < $sum_to_destroy && $worker->get_Is_Head() == false ) { $i++; } } } } abstract class Worker { private $rank; private $proffesion; private $is_Head; private $salary; private $consumed_coffee; private $made_pages; public function __construct($rank, $proffesion, $is_Head, $salary, $consumed_coffe, $made_pages) { $this->set_Rank($rank); $this->set_Proffesion($proffesion); $this->set_Is_Head($is_Head); $this->set_Salary($salary); $this->set_Consumed_Coffee($consumed_coffe); $this->set_Made_Pages($made_pages); } public function set_Rank($rank) { $this->rank = $rank; } public function set_Proffesion($proffesion) { $this->proffesion = $proffesion; } public function set_Is_Head($is_Head) { $this->is_Head = $is_Head; } public function set_Salary($salary) { $this->salary = $salary; } public function set_Consumed_Coffee($consumed_coffee) { $this->consumed_coffee = $consumed_coffee; } public function set_Made_Pages($made_pages) { $this->made_pages = $made_pages; } public function get_Salary($worker) { $rank = $this->rank; if ($rank == 1) { $coef_salary = 1; }elseif ($rank == 2) { $coef_salary = 1.25; }elseif ($rank == 3) { $coef_salary = 1.5; } if ($this->is_Head == true) { $coef_head = 1.5; }else{ $coef_head = 1; } return $this->salary*$coef_salary*$coef_head; } public function get_Coffee($worker) { if ($this->is_Head == true) { $coef_head = 2; }else{ $coef_head = 1; } return $this->consumed_coffee*$coef_head; } public function get_Pages($worker) { if ($this->is_Head == true) { $coef_head = 0; }else{ $coef_head = 1; } return $this->made_pages*$coef_head; } public function get_Proffesion() { return $this->proffesion; } public function get_Rank() { return $this->rank; } public function get_Is_Head() { return $this->is_Head; } } class Manager extends Worker { public function __construct($rank, $is_Head) { parent::__construct($rank, 'Manager', $is_Head, 500, 20, 200); } } class Marketer extends Worker { public function __construct($rank, $is_Head) { parent::__construct($rank, 'Marketer', $is_Head, 400, 15, 150); } } class Engineer extends Worker { public function __construct($rank, $is_Head) { parent::__construct($rank, 'Engineer', $is_Head, 200, 5, 50); } } class Analyst extends Worker { public function __construct($rank, $is_Head) { parent::__construct($rank, 'Analyst', $is_Head, 800, 50, 5); } } $company = new Company; $departament_purchase = new Departament("Purchase"); $departament_purchase->add_Workers(9, 1, 'Manager', false); $departament_purchase->add_Workers(3, 2, 'Manager', false); $departament_purchase->add_Workers(2, 3, 'Manager', false); $departament_purchase->add_Workers(2, 1, 'Marketer', false); $departament_purchase->add_Workers(1, 2, 'Manager', true); $company->add_departament($departament_purchase); $departament_sales = new Departament("Sales"); $departament_sales->add_Workers(12, 1, 'Manager', false); $departament_sales->add_Workers(6, 1, 'Marketer', false); $departament_sales->add_Workers(3, 1, 'Analyst', false); $departament_sales->add_Workers(2, 2, 'Analyst', false); $departament_sales->add_Workers(1, 2, 'Marketer', true); $company->add_departament($departament_sales); $departament_advertising = new Departament("advertising"); $departament_advertising->add_Workers(15, 1, 'Marketer', false); $departament_advertising->add_Workers(10, 2, 'Marketer', false); $departament_advertising->add_Workers(8, 1, 'Manager', false); $departament_advertising->add_Workers(2, 1, 'Engineer', false); $departament_advertising->add_Workers(1, 3, 'Marketer', true); $company->add_departament($departament_advertising); $departament_logistics = new Departament("Logistics"); $departament_logistics->add_Workers(13, 1, 'Manager', false); $departament_logistics->add_Workers(5, 2, 'Manager', false); $departament_logistics->add_Workers(5, 1, 'Engineer', false); $departament_logistics->add_Workers(1, 1, 'Manager', true); $company->add_departament($departament_logistics); function padRight($string, $length) { $x = $length-$long_string; echo $string.$space; } function padLeft($string, $length) { $x = $length-$long_string; echo $space.$string; } function printer($company) { $col1 = 12; $col2 = 12; $col3 = 16; // Заголовок таблицы echo padRight ("Departaments",$col1). padLeft("Workers", $col2) . padLeft("Salary", $col2) . padLeft("Coffee", $col2) . padLeft("Pages", $col2) . padLeft("Salary/Pages", $col3) ."\n"; echo "----------------------------------------------------------------------\n"; $company->print_Info(); echo "----------------------------------------------------------------------\n"; echo padRight('Average', $col2); echo padLeft($company->get_Average_Workers(), $col2); echo padLeft($company->get_Average_Salary(), $col2); echo padLeft($company->get_Average_Coffee(), $col2); echo padLeft($company->get_Average_Pages(), $col2); echo padLeft($company->get_Average_Salary_For_Page(), $col3)."\n"; echo "----------------------------------------------------------------------\n"; echo padRight('VSEGO', $col2); echo padLeft($company->get_Count_Workers(), $col2); echo padLeft($company->get_Count_Salary(), $col2); echo padLeft($company->get_Count_Coffee(), $col2); echo padLeft($company->get_Count_Pages(), $col2); echo padLeft($company->get_Count_Salary_For_Page(), $col3)."\n\n\n"; } printer($company); $company->Destruction_Workers(1.4, Engineer); printer($company);
Standard input is empty
Departaments Workers Salary Coffee Pages Salary/Pages ---------------------------------------------------------------------- Purchase 17 9612.5 350 3100 3.101 Sales 24 13550 610 3325 4.075 advertising 36 16300 575 5450 2.991 Logistics 24 11375 425 3850 2.955 ---------------------------------------------------------------------- Average 25.25 12709.375 490 3931.25 3.2805 ---------------------------------------------------------------------- VSEGO 101 50837.5 1960 15725 13.122 Departaments Workers Salary Coffee Pages Salary/Pages ---------------------------------------------------------------------- Purchase 17 9612.5 350 3100 3.101 Sales 24 13550 610 3325 4.075 advertising 35 16100 570 5400 2.981 Logistics 22 10975 415 3750 2.927 ---------------------------------------------------------------------- Average 24.5 12559.375 486.25 3893.75 3.271 ---------------------------------------------------------------------- VSEGO 98 50237.5 1945 15575 13.084
PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 14 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: count_salary in /home/UH8YEW/prog.php on line 27 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: count_coffee in /home/UH8YEW/prog.php on line 40 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_pages in /home/UH8YEW/prog.php on line 53 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_salary_for_page in /home/UH8YEW/prog.php on line 66 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 14 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: count_salary in /home/UH8YEW/prog.php on line 27 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: count_coffee in /home/UH8YEW/prog.php on line 40 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_pages in /home/UH8YEW/prog.php on line 53 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_salary_for_page in /home/UH8YEW/prog.php on line 66 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Use of undefined constant Engineer - assumed 'Engineer' in /home/UH8YEW/prog.php on line 423 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 174 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 174 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 174 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 174 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 171 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 171 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 14 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: count_salary in /home/UH8YEW/prog.php on line 27 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: count_coffee in /home/UH8YEW/prog.php on line 40 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_pages in /home/UH8YEW/prog.php on line 53 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_salary_for_page in /home/UH8YEW/prog.php on line 66 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_workers in /home/UH8YEW/prog.php on line 14 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: count_salary in /home/UH8YEW/prog.php on line 27 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: count_coffee in /home/UH8YEW/prog.php on line 40 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_coffee in /home/UH8YEW/prog.php on line 147 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_pages in /home/UH8YEW/prog.php on line 53 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: count_salary_for_page in /home/UH8YEW/prog.php on line 66 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155 PHP Notice: Undefined variable: sum_salary in /home/UH8YEW/prog.php on line 139 PHP Notice: Undefined variable: sum_pages in /home/UH8YEW/prog.php on line 155