<?php
// your code goes here
abstract class Department {
protected $employees;
protected $totalEmployees;
protected $totalCoffee;
protected $totalSalary;
protected $totalReports;
abstract function addEmployees($employees);
abstract function totalEmployees();
abstract function totalCoffee();
abstract function totalSalary();
abstract function totalReports();
}
class Sales extends Department {
public function addEmployees($employees) {
$this->employees = $employees;
}
public function totalEmployees() {
$this->totalEmployees = count($this->employees);
return $this->totalEmployees;
}
public function totalCoffee() {
foreach ($this->employees as $employee) {
$this->totalCoffee += $employee->coffeeCount;
}
return $this->totalCoffee;
}
public function totalSalary() {
foreach ($this->employees as $employee) {
$this->totalSalary += $employee->countSalary();
}
return $this->totalSalary;
}
public function totalReports() {
foreach ($this->employees as $employee) {
$this->totalReports += $employee->reports;
}
return $this->totalReports;
}
}
/*
class Purchasing extends Department {
}
class Advertising extends Department {
}
class Logistics extends Department {
}
*/
abstract class Employee {
protected $baseRate;
public $coffeeCount;
protected $reports;
protected $isBoss;
protected $rank;
protected $salary;
abstract function countSalary();
abstract function __construct($rank, $isBoss);
}
class Manager extends Employee {
protected $baseRate = 500;
public $coffeeCount = 20;
protected $reports = 200;
public function __construct($rank, $isBoss) {
$this->rank = $rank;
$this->isBoss = $isBoss;
if ($isBoss) {
$this->coffeeCount = $this->coffeeCount * 2;
$this->reports = 0;
}
}
public function countSalary() {
if ($this->rank == 2) {
$this->salary = $this->baseRate + $this->baseRate * 0.25;
} elseif ($this->rank == 3) {
$this->salary = $this->baseRate + $this->baseRate * 0.50;
} else {
$this->salary = $this->baseRate;
}
if ($this->isBoss) {
$this->salary += $this->salary * 0.50;
}
return $this->salary;
}
}
class marketingExpert extends Employee {
protected $baseRate = 400;
public $coffeeCount = 15;
protected $reports = 150;
public function __construct($rank, $isBoss) {
$this->rank = $rank;
$this->isBoss = $isBoss;
if ($isBoss) {
$this->coffeeCount = $this->coffeeCount * 2;
$this->reports = 0;
}
}
public function countSalary() {
if ($this->rank == 2) {
$this->salary = $this->baseRate + $this->baseRate * 0.25;
} elseif ($this->rank == 3) {
$this->salary = $this->baseRate + $this->baseRate * 0.50;
} else {
$this->salary = $this->baseRate;
}
if ($this->isBoss) {
$this->salary += $this->salary * 0.50;
}
return $this->salary;
}
}
class Engineer extends Employee {
protected $baseRate = 200;
public $coffeeCount = 5;
protected $reports = 50;
public function __construct($rank, $isBoss) {
$this->rank = $rank;
$this->isBoss = $isBoss;
if ($isBoss) {
$this->coffeeCount = $this->coffeeCount * 2;
$this->reports = 0;
}
}
public function countSalary() {
if ($this->rank == 2) {
$this->salary = $this->baseRate + $this->baseRate * 0.25;
} elseif ($this->rank == 3) {
$this->salary = $this->baseRate + $this->baseRate * 0.50;
} else {
$this->salary = $this->baseRate;
}
if ($this->isBoss) {
$this->salary += $this->salary * 0.50;
}
return $this->salary;
}
}
class analyticsExpert extends Employee {
protected $baseRate = 800;
public $coffeeCount = 50;
protected $reports = 5;
public function __construct($rank, $isBoss) {
$this->rank = $rank;
$this->isBoss = $isBoss;
if ($isBoss) {
$this->coffeeCount = $this->coffeeCount * 2;
$this->reports = 0;
}
}
public function countSalary() {
if ($this->rank == 2) {
$this->salary = $this->baseRate + $this->baseRate * 0.25;
} elseif ($this->rank == 3) {
$this->salary = $this->baseRate + $this->baseRate * 0.50;
} else {
$this->salary = $this->baseRate;
}
if ($this->isBoss) {
$this->salary += $this->salary * 0.50;
}
return $this->salary;
}
}
$employees = [
[
new Manager(1, 0), new Manager(1, 0), new Manager(1, 0),
new Manager(1, 0), new Manager(1, 0), new Manager(1, 0),
new Manager(1, 0), new Manager(1, 0), new Manager(1, 0),
new Manager(2, 0), new Manager(2, 0), new Manager(2, 0),
new Manager(3, 0), new Manager(3, 0),
new marketingExpert(1, 0), new marketingExpert(1, 0),
new Manager(2, 1),
],
[],
[],
[],
];
$department = new Sales;
$department->addEmployees($employees[0]);
echo $department->totalSalary();