<?php
header(‘content-type:text/html;charset=utf-8‘);
face Action{
public function level();
public function stealing();
public function hunting();
public function mining();
public function treatment();
public function attack();
public function resistance();
}
class Thieves implements Action{
protected $name;
public function __construct($name=‘盗贼‘){
$this->name = $name;
}
public function level(){
echo ‘当前3级‘;
}
public function stealing(){
echo ‘我可以偷盗‘;
}
public function hunting(){
echo ‘不能打猎‘;
}
public function mining(){
echo ‘不能采矿‘;
}
public function treatment(){
echo ‘不能治疗‘;
}
public function attack(){
echo ‘可以攻击‘;
}
public function resistance(){
echo ‘可以抵抗‘;
}
public function instruction(){
echo ‘我是‘.$this->name;
echo ‘,‘;
$this->level();
echo ‘,‘;
$this->stealing();
echo ‘,‘;
$this->hunting();
echo ‘,‘;
$this->mining();
echo ‘,‘;
$this->treatment();
echo ‘,‘;
$this->attack();
echo ‘,‘;
$this->resistance();
}
}
class Hunter extends Thieves{
public function level(){
echo ‘当前4级‘;
}
public function stealing(){
echo ‘我不能偷盗‘;
}
public function hunting(){
echo ‘但是可以打猎‘;
}
public function mining(){
echo ‘不能采矿‘;
}
public function treatment(){
echo ‘不能治疗‘;
}
public function attack(){
echo ‘但是可以攻击‘;
}
public function resistance(){
echo ‘可以抵抗‘;
}
public function instruction(){
parent::instruction();
}
}
class Boor extends Thieves{
public function level(){
echo ‘当前2级‘;
}
public function stealing(){
echo ‘我不能偷盗‘;
}
public function hunting(){
echo ‘不可以打猎‘;
}
public function mining(){
echo ‘可以采矿‘;
}
public function treatment(){
echo ‘可以治疗‘;
}
public function attack(){
echo ‘可以攻击‘;
}
public function resistance(){
echo ‘可以抵抗‘;
}
public function instruction(){
parent::instruction();
}
}
class Docter extends Thieves{
public function level(){
echo ‘当前5级‘;
}
public function stealing(){
echo ‘我不能偷盗‘;
}
public function hunting(){
echo ‘不可以打猎‘;
}
public function mining(){
echo ‘不可以采矿‘;
}
public function treatment(){
echo ‘只可以治疗‘;
}
public function attack(){
echo ‘不可以攻击‘;
}
public function resistance(){
echo ‘不可以抵抗‘;
}
public function instruction(){
parent::instruction();
}
}
class Ranker extends Thieves{
public function level(){
echo ‘当前10级‘;
}
public function stealing(){
echo ‘作为兵士我不能偷盗‘;
}
public function hunting(){
echo ‘不可以打猎‘;
}
public function mining(){
echo ‘不可以采矿‘;
}
public function treatment(){
echo ‘作为兵士我不是医生不可以治疗‘;
}
public function attack(){
echo ‘作为兵士可以攻击‘;
}
public function resistance(){
echo ‘可以抵抗‘;
}
public function instruction(){
parent::instruction();
}
}
$dz = new Thieves(‘盗贼‘);
$dz->instruction();
echo‘<br>‘;
echo‘<br>‘;
$lr = new Hunter(‘猎人‘);
$lr->instruction();
echo‘<br>‘;
echo‘<br>‘;
$nm = new Boor(‘农民‘);
$nm->instruction();
echo‘<br>‘;
echo‘<br>‘;
$ys = new Docter(‘医生‘);
$ys->instruction();
echo‘<br>‘;
echo‘<br>‘;
$bs = new Ranker(‘士兵‘);
$bs->instruction();