Created
June 3, 2018 16:20
-
-
Save soner8/c5f1213f6e6e67acd7ef1943d5013522 to your computer and use it in GitHub Desktop.
Promise
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 Monstre { | |
constructor (options = {}){ | |
this.health = 100; | |
this.name = options.name; | |
} | |
heal() { | |
this.health= this.health + 10; | |
return this.health; | |
} | |
} | |
class MiniMonstre extends Monstre { | |
constructor (options = {}){ | |
super(options); | |
this.health = 50; | |
} | |
heal() { | |
this.health= this.health + 5; | |
return this.health; | |
} | |
} | |
module.exports = {Monstre,MiniMonstre}; | |
const p1 = new Monstre ({name:"Booba"}); | |
const p2 = new MiniMonstre ({name: "Babou"}); | |
console.log(p1); | |
console.log(p1.heal()); | |
console.log(p1); | |
console.log(p2); | |
console.log(p2.heal()); | |
console.log(p2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment