fork download
  1. <?php
  2.  
  3. abstract class Department {
  4. public $employees = array();
  5. public $moneyConsumption;
  6. public $coffeeConsumption;
  7. public $reportsGeneration;
  8. public $toogreeksPerPage;
  9.  
  10. public function name () {
  11.  
  12. }
  13. }
  14. class Purchasing extends Department {
  15. public function __construct() {
  16. $i = 0;
  17. while ($i < 9){
  18. $this->employees[] = new Manager(1, false);
  19. $i = $i + 1;
  20. }
  21. }
  22. }
  23. class Sales extends Department {
  24.  
  25. }
  26. class Marketing extends Department {
  27.  
  28. }
  29. class Logistics extends Department {
  30.  
  31. }
  32.  
  33. abstract class Employee {
  34. public $rank;
  35. public $isBoss;
  36. public $salary;
  37. public $coffee;
  38. public $reports;
  39.  
  40. public function countSalary($salary) {
  41. if ($this->rank == 2) {
  42. $salary = $salary * 1.25;
  43. }elseif ($this->rank == 3) {
  44. $salary = $salary * 1.5;
  45. }
  46. if ($this->isBoss == true) {
  47. $salary = $salary * 1.5;
  48. }
  49. return $salary;
  50. }
  51. public function countCoffee($coffee) {
  52. if ($this->isBoss == true) {
  53. $coffee = $coffee * 2;
  54. }
  55. return $coffee;
  56. }
  57. public function countReports($reports) {
  58. if ($this->isBoss == true) {
  59. $reports = 0;
  60. }
  61. return $reports;
  62. }
  63. }
  64.  
  65. class Manager extends Employee {
  66. public function __construct($rank, $isBoss) {
  67. $salary = 500;
  68. $coffee = 20;
  69. $reports = 200;
  70. $this->rank = $rank;
  71. $this->isBoss = $isBoss;
  72. $this->salary = $this->countSalary($salary);
  73. $this->coffee = $this->countCoffee($coffee);
  74. $this->reports = $this->countReports($reports);
  75. }
  76. }
  77. class Marketer extends Employee {
  78. public function __construct($rank, $isBoss) {
  79. $salary = 400;
  80. $coffee = 15;
  81. $reports = 150;
  82. $this->rank = $rank;
  83. $this->isBoss = $isBoss;
  84. $this->salary = $this->countSalary($salary);
  85. $this->coffee = $this->countCoffee($coffee);
  86. $this->reports = $this->countReports($reports);
  87. }
  88. }
  89. class Engineer extends Employee {
  90. public function __construct($rank, $isBoss) {
  91. $salary = 200;
  92. $coffee = 5;
  93. $reports = 50;
  94. $this->rank = $rank;
  95. $this->isBoss = $isBoss;
  96. $this->salary = $this->countSalary($salary);
  97. $this->coffee = $this->countCoffee($coffee);
  98. $this->reports = $this->countReports($reports);
  99. }
  100. }
  101. class Analyst extends Employee {
  102. public function __construct($rank, $isBoss) {
  103. $salary = 800;
  104. $coffee = 50;
  105. $reports = 5;
  106. $this->rank = $rank;
  107. $this->isBoss = $isBoss;
  108. $this->salary = $this->countSalary($salary);
  109. $this->coffee = $this->countCoffee($coffee);
  110. $this->reports = $this->countReports($reports);
  111. }
  112. }
  113.  
  114. $purchasing = new Purchasing;
  115. 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
}