<?php
abstract class Worker
{
private $department;
private $rank;
private $isChief;
private $baseSalary;
private $coffeeConsumptionRate;
private $productionPerMount;
private $productionType;
public function __construct( $department, $rank, $chief )
{
$this->department = $department;
$this->rank = $rank;
$this->isChief = $chief;
}
public function getCoffeeConsumption()
{
if ( $this->isChief )
{
$coffee = $coffeeConsumptionRate*1.5;
}
else
{
$coffee = $coffeeConsumptionRate;
}
return $coffee;
}
public function getSalary()
{
switch( $this->rank )
{
case 1:
$salary = $baseSalary;
break;
case 2:
$salary = $baseSalary*1.25;
break;
case 3:
$salary = $baseSalary*1.5;
break;
}
if( $isChief )
{
$salary*= 1.5;
}
return $salary;
}
abstract function getInfos();
}
class Manager extends Worker
{
private $coffeeConsumptionRate = 20;
private $baseSalary = 500;
private $productionPerMount = 200;
private $productionType = "страница отчёта";
public function getInfos()
{
echo "Это менеджер ";
echo $this->rank;
echo " уровня из департамента ";
echo $this->department;
if ($this->isChief)
{
echo "\nОн начальник этого департамента.";
}
echo "\nПолучает ";
echo $this->getSalary();
echo " единиц валюты в месяц\n";
echo "Выпивает ";
echo $this->getCoffeeConsumption();
echo " литров кофе в месяц\n";
}
}
$a = new Manager( "торговый", 2, true );
$a->getInfos();