Last active
March 31, 2018 11:33
js class, constructor, etc
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
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