Skip to content

Instantly share code, notes, and snippets.

@VictorFursa
Last active September 1, 2016 13:03
Show Gist options
  • Save VictorFursa/27ee12c642cc80ba19b07ae7c8e2ab5b to your computer and use it in GitHub Desktop.
Save VictorFursa/27ee12c642cc80ba19b07ae7c8e2ab5b to your computer and use it in GitHub Desktop.
WOW
<?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;
}
}
<?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();
<?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