<?php
class Worker {
public $name;
public $level;
public $chief; // Принимает значения True or False
function __construct($workers_name, $workers_level, $is_chief) {
$name = $workers_name;
$level = $workers_level;
$chief = $is_chief;
}
}
class Manager extends Worker {
protected $paid = 500;
protected $pages = 200;
protected $coffe = 20;
public function drinkCoffe($this) {
if ($this->chief == True) {
return ($coffe * 2);
} else {
return $coffe;
}
}
}
$Peter = new Manager('P. Stivenson', 2, True);
echo drinkCoffe($Peter);
/* Стоит создать для каждого типа работника - отдельный подкласс Worker */
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKY2xhc3MgV29ya2VyIHsKCXB1YmxpYyAkbmFtZTsKCXB1YmxpYyAkbGV2ZWw7CglwdWJsaWMgJGNoaWVmOyAvLyDQn9GA0LjQvdC40LzQsNC10YIg0LfQvdCw0YfQtdC90LjRjyBUcnVlIG9yIEZhbHNlCgkKCQoJZnVuY3Rpb24gX19jb25zdHJ1Y3QoJHdvcmtlcnNfbmFtZSwgJHdvcmtlcnNfbGV2ZWwsICRpc19jaGllZikgewoJCSRuYW1lID0gJHdvcmtlcnNfbmFtZTsKCQkkbGV2ZWwgPSAkd29ya2Vyc19sZXZlbDsKCQkkY2hpZWYgPSAkaXNfY2hpZWY7Cgl9Cn0KY2xhc3MgTWFuYWdlciBleHRlbmRzIFdvcmtlciB7CgkKCXByb3RlY3RlZCAkcGFpZCA9IDUwMDsKCXByb3RlY3RlZCAkcGFnZXMgPSAyMDA7Cglwcm90ZWN0ZWQgJGNvZmZlID0gMjA7CgkKCXB1YmxpYyBmdW5jdGlvbiBkcmlua0NvZmZlKCR0aGlzKSB7CgkJaWYgKCR0aGlzLT5jaGllZiA9PSBUcnVlKSB7CgkJCXJldHVybiAoJGNvZmZlICogMik7CgkJfSBlbHNlIHsKCQkJcmV0dXJuICRjb2ZmZTsKCQl9Cgl9Cn0KJFBldGVyID0gbmV3IE1hbmFnZXIoJ1AuIFN0aXZlbnNvbicsIDIsIFRydWUpOwplY2hvIGRyaW5rQ29mZmUoJFBldGVyKTsKCi8qINCh0YLQvtC40YIg0YHQvtC30LTQsNGC0Ywg0LTQu9GPINC60LDQttC00L7Qs9C+INGC0LjQv9CwINGA0LDQsdC+0YLQvdC40LrQsCAtINC+0YLQtNC10LvRjNC90YvQuSDQv9C+0LTQutC70LDRgdGBIFdvcmtlciAqLwo/Pg==