Skip to content

Instantly share code, notes, and snippets.

@soner8
Created June 3, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soner8/c5f1213f6e6e67acd7ef1943d5013522 to your computer and use it in GitHub Desktop.
Save soner8/c5f1213f6e6e67acd7ef1943d5013522 to your computer and use it in GitHub Desktop.
Promise
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