Last active
March 31, 2018 11:33
-
-
Save TheCodingLady/8bc9a14bcc6d4cfb7bd148564ff5eda4 to your computer and use it in GitHub Desktop.
js class, constructor, etc
This file contains 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
class Monster { | |
constructor(options) { | |
this.name = name; | |
this.health = 100; | |
} | |
heal() { | |
return this.health += 10; | |
} | |
} | |
class MiniMonster extends Monster { | |
constructor(options) { | |
super(name); | |
this.health = 50; | |
} | |
heal() { | |
return this.health += 5; | |
} | |
} | |
let Cheeto_Man = new Monster(name = "Donald"); | |
let Robo_Dog = new MiniMonster(name = "Spot"); | |
console.log(Cheeto_Man.name + " is " + Cheeto_Man.health + "% " + "monster."); | |
console.log(Robo_Dog.name + " is " + Robo_Dog.health + "% " + "monster."); | |
module.exports = { | |
Monster, | |
MiniMonster | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment