<?php
abstract class Employee {
/**
* rank (aka grade) within enterprise: 1, 2 or 3
*/
protected int $grade;
/**
* base rate for figuring out the actual pay
* can be int or float
*/
protected $baseRate;
/**
* is in charge of department?
*/
protected bool $chief;
/**
* base Coffee Consumption
* can be int or float
*/
protected $baseCoffeeConsumption;
/**
* base Paperwork Produced
*/
protected int $basePaperworkProduced;
public function __construct(int $grade, bool $chief = false) {
$this->grade = $grade;
$this->chief = $chief;
}
/**
* get Actual Pay
*/
public function getActualPay() {
$rate = $this->baseRate;
if ($this->grade == 2) {
$rate *= 1.25;
} elseif ($this->grade == 3) {
$rate = $rate * 1.5;
}
return $this->chief ? $rate * 2 : $rate;
}
/**
* get Actual Coffee Consumption
*/
public function getActualCoffeeConsumption() {
return $this->chief ? $this->baseCC * 2 : $this->baseCC;
}
/**
* get Actual Paperwork Produced
*/
public function getAPP(): int {
return $this->chief ? 0 : $this->basePP;
}
}
class Manager extends Employee {
protected $baseRate = 500;
protected $baseCC = 20;
protected int $basePP = 200;
}
class Marketer extends Employee {
protected $baseRate = 400;
protected $baseCC = 15;
protected int $basePP = 150;
}
class Engineer extends Employee {
protected $baseRate = 200;
protected $baseCC = 5;
protected int $basePP = 50;
}
class Analyst extends Employee {
protected $baseRate = 800;
protected $baseCC = 50;
protected int $basePP = 5;
}