<?php
abstract class Worker
{
public $department;
public $rank;
public $isChief;
public $baseSalary;
public $coffeeConsumptionRate;
public $productionPerMount;
public $productionType;
public function __construct( $department, $rank, $chief )
{
$this->department = $department;
$this->rank = $rank;
$this->isChief = $chief;
}
public function getCoffeeConsumption()
{
if ( $this->isChief )
{
$coffee = $this->$coffeeConsumptionRate*1.5;
}
else
{
$coffee = $this->$coffeeConsumptionRate;
}
return $coffee;
}
public function getSalary()
{
switch( $this->rank )
{
case 1:
$salary = $this->$baseSalary;
break;
case 2:
$salary = $this->$baseSalary*1.25;
break;
case 3:
$salary = $this->$baseSalary*1.5;
break;
}
if( $this->$isChief )
{
$salary*= 1.5;
}
return $salary;
}
abstract function getInfos();
}
class Manager extends Worker
{
public $coffeeConsumptionRate = 20;
public $baseSalary = 500;
public $productionPerMount = 200;
public $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();