fork download
  1. <?php
  2.  
  3. abstract class Employee {
  4. /**
  5. * rank (aka grade) within enterprise: 1, 2 or 3
  6. */
  7. protected int $grade;
  8. /**
  9. * base rate for figuring out the actual pay
  10. * can be int or float
  11. */
  12. protected $baseRate;
  13. /**
  14. * is in charge of department?
  15. */
  16. protected bool $chief;
  17. /**
  18. * base Coffee Consumption
  19. * can be int or float
  20. */
  21. protected $baseCoffeeConsumption;
  22. /**
  23. * base Paperwork Produced
  24. */
  25. protected int $basePaperworkProduced;
  26.  
  27. public function __construct(int $grade, bool $chief = false) {
  28. $this->grade = $grade;
  29. $this->chief = $chief;
  30. }
  31.  
  32. /**
  33. * get Actual Pay
  34. */
  35. public function getActualPay() {
  36. $rate = $this->baseRate;
  37. if ($this->grade == 2) {
  38. $rate *= 1.25;
  39. } elseif ($this->grade == 3) {
  40. $rate = $rate * 1.5;
  41. }
  42.  
  43. return $this->chief ? $rate * 2 : $rate;
  44. }
  45.  
  46. /**
  47. * get Actual Coffee Consumption
  48. */
  49. public function getActualCoffeeConsumption() {
  50. return $this->chief ? $this->baseCC * 2 : $this->baseCC;
  51. }
  52.  
  53. /**
  54. * get Actual Paperwork Produced
  55. */
  56. public function getAPP(): int {
  57. return $this->chief ? 0 : $this->basePP;
  58. }
  59. }
  60.  
  61. class Manager extends Employee {
  62. protected $baseRate = 500;
  63. protected $baseCC = 20;
  64. protected int $basePP = 200;
  65. }
  66.  
  67. class Marketer extends Employee {
  68. protected $baseRate = 400;
  69. protected $baseCC = 15;
  70. protected int $basePP = 150;
  71. }
  72.  
  73. class Engineer extends Employee {
  74. protected $baseRate = 200;
  75. protected $baseCC = 5;
  76. protected int $basePP = 50;
  77. }
  78.  
  79. class Analyst extends Employee {
  80. protected $baseRate = 800;
  81. protected $baseCC = 50;
  82. protected int $basePP = 5;
  83. }
Runtime error #stdin #stdout #stderr 0.04s 24088KB
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/ksWZPz/prog.php on line 7