Last active
September 1, 2016 13:03
-
-
Save VictorFursa/27ee12c642cc80ba19b07ae7c8e2ab5b to your computer and use it in GitHub Desktop.
WOW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Character | |
{ | |
public $lvl= 1; | |
public $name; | |
public $power; | |
public $intellect; | |
abstract function updateStat(); | |
public function __construct($name) | |
{ | |
$this->name = $name; | |
} | |
public function levelUp($lvl) | |
{ | |
$this->power = $lvl + $this->power; | |
$this->intellect = $lvl + $this->intellect; | |
} | |
public function getStat() | |
{ | |
echo '<h1>' . $this->name . '</h1>'.'интелект' . $this->intellect . '<br>' . 'сила' . $this->power; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "Character.php"; | |
class Mage extends Character | |
{ | |
public $power = 1; | |
public $intellect = 2; | |
public function updateStat(){ | |
$this->intellect +=212; | |
$this->power +=132; | |
} | |
} | |
$mage = new Mage('Mage'); | |
$mage->levelUp(333); | |
$mage->updateStat(); | |
$mage->getStat(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "Character.php"; | |
class Warrior extends Character | |
{ | |
public $power = 2; | |
public $intellect = 1; | |
public function updateStat(){ | |
$this->intellect +=21; | |
$this->power +=12; | |
} | |
} | |
$warrior = new Warrior('Warrior'); | |
$warrior->levelUp(22); | |
$warrior->updateStat(); | |
$warrior->getStat(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment