fork download
  1. <?php
  2.  
  3. abstract class Employee {
  4. const MANAGER = "Manager";
  5. const MARKETER = "Marketer";
  6. const ENGINEER = "Engineer";
  7. const ANALYST = "Analyst";
  8.  
  9. protected int $grade;
  10. protected bool $chief;
  11.  
  12. public function __construct(int $grade, bool $chief = false) {
  13. $this->grade = $grade;
  14. $this->chief = $chief;
  15. }
  16.  
  17. public function getBaseRate();
  18.  
  19. public function getActualPay() {
  20. $rate = $this->getBaseRate();
  21. if ($this->grade == 2) {
  22. $rate *= 1.25;
  23. } elseif ($this->grade == 3) {
  24. $rate = $rate * 1.5;
  25. }
  26.  
  27. return $this->chief ? $rate * 2 : $rate;
  28. }
  29.  
  30. public function getBaseCoffeeConsumption();
  31.  
  32. public function getActualCoffeeConsumption() {
  33. return $this->chief ? $this->getBaseCoffeeConsumption() * 2 : $this->getBaseCoffeeConsumption();
  34. }
  35.  
  36. public function getBasePaperworkProduced();
  37.  
  38. public function getActualPaperworkProduced(): int {
  39. return $this->chief ? 0 : $this->getBasePaperworkProduced();
  40. }
  41. }
  42.  
  43. class Manager extends Employee {
  44. protected $baseRate = 500;
  45. protected $baseCoffeeConsumption = 20;
  46. protected int $basePaperworkProduced = 200;
  47.  
  48. public function getBaseRate() {
  49. return $this->baseRate;
  50. }
  51.  
  52. public function getBaseCoffeeConsumption() {
  53. return $this->baseCoffeeConsumption;
  54. }
  55.  
  56. public function getBasePaperworkProduced() {
  57. return $this->basePaperworkProduced;
  58. }
  59. }
  60.  
  61. class Marketer extends Employee {
  62. protected $baseRate = 400;
  63. protected $baseCoffeeConsumption = 15;
  64. protected int $basePaperworkProduced = 150;
  65.  
  66. public function getBaseRate() {
  67. return $this->baseRate;
  68. }
  69.  
  70. public function getBaseCoffeeConsumption() {
  71. return $this->baseCoffeeConsumption;
  72. }
  73.  
  74. public function getBasePaperworkProduced() {
  75. return $this->basePaperworkProduced;
  76. }
  77. }
  78.  
  79. class Engineer extends Employee {
  80. protected $baseRate = 200;
  81. protected $baseCoffeeConsumption = 5;
  82. protected int $basePaperworkProduced = 50;
  83.  
  84. public function getBaseRate() {
  85. return $this->baseRate;
  86. }
  87.  
  88. public function getBaseCoffeeConsumption() {
  89. return $this->baseCoffeeConsumption;
  90. }
  91.  
  92. public function getBasePaperworkProduced() {
  93. return $this->basePaperworkProduced;
  94. }
  95. }
  96.  
  97. class Analyst extends Employee {
  98. protected $baseRate = 800;
  99. protected $baseCoffeeConsumption = 50;
  100. protected int $basePaperworkProduced = 5;
  101.  
  102. public function getBaseRate() {
  103. return $this->baseRate;
  104. }
  105.  
  106. public function getBaseCoffeeConsumption() {
  107. return $this->baseCoffeeConsumption;
  108. }
  109.  
  110. public function getBasePaperworkProduced() {
  111. return $this->basePaperworkProduced;
  112. }
  113. }
Runtime error #stdin #stdout #stderr 0.02s 24380KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /home/9ysvdp/prog.php on line 9