PHP Inheritance 2

Source: Internet
Author: User

<?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 = ' rogue ') {
$this->name = $name;
}
Public Function level () {
Echo ' current level 3 ';
}
Public function stealing () {
Echo ' I can steal ';
}
Public Function Hunting () {
Echo ' Can't hunt ';
}
Public Function Mining () {
Echo ' cannot mining ';
}
Public Function treatment () {
Echo ' cannot be treated ';
}
Public Function Attack () {
Echo ' can attack ';
}
Public Function resistance () {
Echo ' can resist ';
}

Public Function instruction () {
Echo ' I am '. $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 ' current level 4 ';
}
Public function stealing () {
Echo ' I can't steal ';
}
Public Function Hunting () {
Echo ' but can hunt ';
}
Public Function Mining () {
Echo ' cannot mining ';
}
Public Function treatment () {
Echo ' cannot be treated ';
}
Public Function Attack () {
Echo ' but can attack ';
}
Public Function resistance () {
Echo ' can resist ';
}
Public Function instruction () {
Parent::instruction ();
}
}
Class Boor extends thieves{
Public Function level () {
Echo ' current level 2 ';
}
Public function stealing () {
Echo ' I can't steal ';
}
Public Function Hunting () {
Echo ' Can not hunt ';
}
Public Function Mining () {
Echo ' can mining ';
}
Public Function treatment () {
Echo ' can be treated ';
}
Public Function Attack () {
Echo ' can attack ';
}
Public Function resistance () {
Echo ' can resist ';
}
Public Function instruction () {
Parent::instruction ();
}
}
Class Docter extends thieves{
Public Function level () {
Echo ' current level 5 ';
}
Public function stealing () {
Echo ' I can't steal ';
}
Public Function Hunting () {
Echo ' Can not hunt ';
}
Public Function Mining () {
Echo ' cannot be mined ';
}
Public Function treatment () {
Echo ' can only be treated ';
}
Public Function Attack () {
Echo ' can not attack ';
}
Public Function resistance () {
Echo ' can not resist ';
}
Public Function instruction () {
Parent::instruction ();
}
}
Class Ranker extends thieves{
Public Function level () {
Echo ' current level 10 ';
}
Public function stealing () {
Echo ' I can't steal as a soldier ';
}
Public Function Hunting () {
Echo ' Can not hunt ';
}
Public Function Mining () {
Echo ' cannot be mined ';
}
Public Function treatment () {
Echo ' As a soldier I am not a doctor can not cure ';
}
Public Function Attack () {
Echo ' Can attack as a soldier ';
}
Public Function resistance () {
Echo ' can resist ';
}
Public Function instruction () {
Parent::instruction ();
}
}
$dz = new Thieves (' rogue ');
$dz->instruction ();
Echo ' <br> ';
Echo ' <br> ';
$LR = new Hunter (' Hunter ');
$LR->instruction ();
Echo ' <br> ';
Echo ' <br> ';
$NM = new Boor (' Farmers ');
$NM->instruction ();
Echo ' <br> ';
Echo ' <br> ';
$ys = new Docter (' Doctor ');
$ys->instruction ();
Echo ' <br> ';
Echo ' <br> ';
$bs = new Ranker (' Soldier ');
$bs->instruction ();

PHP Inheritance 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.