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