fork(1) download
  1. <?php
  2.  
  3. abstract class Employee{
  4.  
  5. public $salary;
  6. public $pages;
  7. public $cofee;
  8. public $name;
  9.  
  10.  
  11. function __construct($quantity, $rank){
  12.  
  13. $this->quantity = $quantity;
  14. $this->rank = $rank;
  15. }
  16.  
  17. function getSalary(){
  18. $multiply=1;
  19. switch($this->rank){
  20. case 2:
  21. $multiply=1.25;
  22. break;
  23. case 3:
  24. $multiply=1.50;
  25. break;
  26. }
  27. $getSalary=$this->salary*$multiply*$this->quantity;
  28. return $getSalary;
  29. }
  30.  
  31. function getCofee(){
  32. $getCofee=$this->quantity*$this->cofee;
  33. return $getCofee;
  34. }
  35.  
  36. function getPages(){
  37. $getPages=$this->quantity*$this->pages;
  38. return $getPages;
  39. }
  40.  
  41. }
  42.  
  43. class Manager extends Employee{
  44. public $name="Менеджер";
  45. public $salary = 500;
  46. public $cofee = 20;
  47. public $pages = 200;
  48. }
  49.  
  50. class Market extends Employee{
  51. public $name = "Маркетолог";
  52. public $salary = 400;
  53. public $cofee = 15;
  54. public $pages = 150;
  55. }
  56.  
  57. class Engineer extends Employee {
  58. public $name = "Инженер";
  59. public $salary = 200;
  60. public $cofee = 5;
  61. public $pages = 50;
  62. }
  63.  
  64. class Analyst extends Employee {
  65. public $name = "Аналитик";
  66. public $salary = 800;
  67. public $cofee = 50;
  68. public $pages = 5;
  69. }
  70.  
  71.  
  72. class Department{
  73. public $workers;
  74. public $costs;
  75.  
  76. function __construct($name){
  77. $this->name = $name;
  78. return $this->name;
  79. }
  80. }
  81.  
  82. $department1= array(
  83. new Manager(9, 1),
  84. new Manager(3, 2),
  85. new Manager(2, 3),
  86. new Market(2, 1),
  87. 'name'=>'закупок'
  88. );
  89.  
  90.  
  91. function createDepartment($data){
  92. $department = new Department($data['name']);
  93. foreach($data as $key=> $workers){
  94. if($key=='name'){
  95. continue;
  96. }
  97. echo $key;
  98. }
  99.  
  100. }
  101.  
  102. createDepartment($department1);
  103.  
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
123