<?php
abstract class Employee {
abstract public $rang;
abstract public $solary;
abstract public $leader;
public function __construct($rang = 1, $leader = false) {
$this->rang = $rang;
$this->leader = $leader;
self::calculateSolary();
}
public function calculateSolary() {
switch ($this->rang) {
case 2:
$this->solary = $this->solary + ($this->solary * 0.25);
break;
case 3:
$this->solary = $this->solary + ($this->solary * 0.50);
break;
}
if ($leader) {
$this->solary = $this->solary + ($this->solary * 0.50);
}
return $this->solary;
}
}
class Engineer extends Employee {
public $solary = 500;
}
$engineer = new Engineer(2);
...
PD9waHAKCmFic3RyYWN0IGNsYXNzIEVtcGxveWVlIHsKCWFic3RyYWN0IHB1YmxpYyAkcmFuZzsKCWFic3RyYWN0IHB1YmxpYyAkc29sYXJ5OwoJYWJzdHJhY3QgcHVibGljICRsZWFkZXI7CgkKCXB1YmxpYyBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkcmFuZyA9IDEsICRsZWFkZXIgPSBmYWxzZSkgewoJCSR0aGlzLT5yYW5nID0gJHJhbmc7CgkJJHRoaXMtPmxlYWRlciA9ICRsZWFkZXI7CgkJCgkJc2VsZjo6Y2FsY3VsYXRlU29sYXJ5KCk7Cgl9CgkKCXB1YmxpYyBmdW5jdGlvbiBjYWxjdWxhdGVTb2xhcnkoKSB7CgkJc3dpdGNoICgkdGhpcy0+cmFuZykgewoJCQljYXNlIDI6CgkJCQkkdGhpcy0+c29sYXJ5ID0gJHRoaXMtPnNvbGFyeSArICgkdGhpcy0+c29sYXJ5ICogMC4yNSk7CgkJCQlicmVhazsKCQkJY2FzZSAzOgoJCQkJJHRoaXMtPnNvbGFyeSA9ICR0aGlzLT5zb2xhcnkgKyAoJHRoaXMtPnNvbGFyeSAqIDAuNTApOwoJCQkJYnJlYWs7CgkJfQoJCgkJaWYgKCRsZWFkZXIpIHsKCQkJJHRoaXMtPnNvbGFyeSA9ICR0aGlzLT5zb2xhcnkgKyAoJHRoaXMtPnNvbGFyeSAqIDAuNTApOwoJCX0KCQoJCXJldHVybiAkdGhpcy0+c29sYXJ5OwoJfQoJCn0KCmNsYXNzIEVuZ2luZWVyIGV4dGVuZHMgRW1wbG95ZWUgewoJcHVibGljICRzb2xhcnkgPSA1MDA7Cn0KCgokZW5naW5lZXIgPSBuZXcgRW5naW5lZXIoMik7CgouLi4K