Last active
December 23, 2018 20:06
-
-
Save ioxua/207c0ef0f4f4dabbbccc496d1a262829 to your computer and use it in GitHub Desktop.
Dwemthy's Array ES6 -- medium post 1
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 Creature { | |
constructor() { | |
this.traits("life", "strength", "charisma", "weapon"); | |
} | |
traits(...args) { | |
args.forEach(name => { | |
Object.defineProperty(this, name, { | |
writable: true | |
}); | |
}); | |
} | |
// Omitted a LOT of methods here. | |
} | |
class Rabbit extends Creature { | |
constructor() { | |
super(); | |
this.traits("bombs"); | |
this.bombs = 3; | |
this.life = 10; | |
this.strength = 2; | |
this.charisma = 44; | |
this.weapon = 4; | |
this.bombs = 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment