fork download
<?php
error_reporting(-1);
mb_internal_encoding('utf-8');

abstract class Department {
    public $employees = array();
    public $moneyConsumption;
    public $coffeeConsumption;
    public $reportsGeneration;
    public $toogreeksPerPage;
    
    public function name () {
        
    }
}
class Purchasing extends Department {
    public function __construct() {
    	$i = 0;
        while ($i < 9){
	        $this->employees[] = new Manager(1, false);
	        $i = $i + 1;
        }
    }
}
class Sales extends Department {
    
}
class Marketing extends Department {
    
}
class Logistics extends Department {
    
}

abstract class Employee {
    public $rank;
    public $isBoss;
    public $salary;
    public $coffee;
    public $reports;
    
    public function countSalary($salary) {
        if ($this->rank == 2) {
            $salary =  $salary * 1.25;
        }elseif ($this->rank == 3) {
            $salary = $salary * 1.5;
        }
        if ($this->isBoss == true) {
            $salary = $salary * 1.5;
        }
        return $salary;
    }
    public function countCoffee($coffee) {
        if ($this->isBoss == true) {
            $coffee = $coffee * 2;
        }
        return $coffee;
    }
    public function countReports($reports) {
        if ($this->isBoss == true) {
            $reports = 0;
        }
        return $reports;
    }
}

class Manager extends Employee {
    public function __construct($rank, $isBoss) {
    	$salary = 500;
    	$coffee = 20;
    	$reports = 200;
        $this->rank = $rank;
        $this->isBoss = $isBoss;
        $this->salary = $this->countSalary($salary);
        $this->coffee = $this->countCoffee($coffee);
        $this->reports = $this->countReports($reports);
    }
}
class Marketer extends Employee {
    public function __construct($rank, $isBoss) {
    	$salary = 400;
    	$coffee = 15;
    	$reports = 150;
        $this->rank = $rank;
        $this->isBoss = $isBoss;
        $this->salary = $this->countSalary($salary);
        $this->coffee = $this->countCoffee($coffee);
        $this->reports = $this->countReports($reports);
    }
}
class Engineer extends Employee {
    public function __construct($rank, $isBoss) {
    	$salary = 200;
    	$coffee = 5;
    	$reports = 50;
        $this->rank = $rank;
        $this->isBoss = $isBoss;
        $this->salary = $this->countSalary($salary);
        $this->coffee = $this->countCoffee($coffee);
        $this->reports = $this->countReports($reports);
    }
}
class Analyst extends Employee {
    public function __construct($rank, $isBoss) {
    	$salary = 800;
    	$coffee = 50;
    	$reports = 5;
        $this->rank = $rank;
        $this->isBoss = $isBoss;
        $this->salary = $this->countSalary($salary);
        $this->coffee = $this->countCoffee($coffee);
        $this->reports = $this->countReports($reports);
    }
}

$purchasing = new Purchasing;
var_dump($purchasing);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
object(Purchasing)#1 (5) {
  ["employees"]=>
  array(9) {
    [0]=>
    object(Manager)#2 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [1]=>
    object(Manager)#3 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [2]=>
    object(Manager)#4 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [3]=>
    object(Manager)#5 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [4]=>
    object(Manager)#6 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [5]=>
    object(Manager)#7 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [6]=>
    object(Manager)#8 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [7]=>
    object(Manager)#9 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
    [8]=>
    object(Manager)#10 (5) {
      ["rank"]=>
      int(1)
      ["isBoss"]=>
      bool(false)
      ["salary"]=>
      int(500)
      ["coffee"]=>
      int(20)
      ["reports"]=>
      int(200)
    }
  }
  ["moneyConsumption"]=>
  NULL
  ["coffeeConsumption"]=>
  NULL
  ["reportsGeneration"]=>
  NULL
  ["toogreeksPerPage"]=>
  NULL
}