fork download
  1. <?php
  2.  
  3. /* ООП дается мне сложно. Поэтому любому замечанию буду рад.
  4. Нужен абстрактный класс с публичными свойствами $rank и $isBoss ( их мы добавим в конструктор - считывать работника ) */
  5.  
  6.  
  7.  
  8. abstract class Employee
  9. {
  10. protected $profession;
  11. public $rank;
  12. public $isBoss;
  13.  
  14. //запрашивать ранк и босс ли он
  15. public function __construct($rank,$isBoss)
  16. {
  17.  
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24.  
  25. Class Manager extends Employee
  26. {
  27. protected $profession = "Manager";
  28. public function Hello(){echo"hello";}
  29. }
  30.  
  31.  
  32. Class Marketer extends Employee
  33. {
  34. protected $profession = "Marketer";
  35.  
  36. }
  37.  
  38.  
  39. Class Engineer extends Employee
  40. {
  41. protected $profession = "Engineer";
  42.  
  43. }
  44.  
  45.  
  46.  
  47. class Department
  48. {
  49.  
  50.  
  51. public function AddWorker($departments)
  52. {
  53. $this->Hello();
  54. }
  55.  
  56. public function __construct(){}
  57. }
  58.  
  59.  
  60. $departments = array(0 => "Purchase", 1 => "Buying", 2 => "Ad", 3 => "Logistics" );
  61.  
  62. $company = new Department;
  63. $company->AddWorker($departments[0]);
Runtime error #stdin #stdout #stderr 0.01s 82880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Call to undefined method Department::Hello() in /home/BwvayW/prog.php:54
Stack trace:
#0 /home/BwvayW/prog.php(64): Department->AddWorker('Purchase')
#1 {main}
  thrown in /home/BwvayW/prog.php on line 54