Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let state = ['Water', 'Fire', 'Earth', 'Air'];
- class Melon {
- constructor(weight, melonSort) {
- if (new.target === Melon) {
- throw new Error(`Abstract class cannot be instantiated directly`);
- }
- this.weight = weight;
- this.melonSort = melonSort;
- this._elemIndex = this.weight * this.melonSort.length;
- }
- get elementIndex() {
- return this._elemIndex;
- }
- toString() {
- let a;
- if (this instanceof Melolemonmelon) {
- a = state[0];
- } else {
- a = this.constructor.name.split('melon')[0];
- }
- return `Element: ${a}\nSort: ${this.melonSort}\nElement Index: ${this.elementIndex}`;
- }
- }
- class Watermelon extends Melon {
- constructor(weight, melonSort) {
- super(weight, melonSort);
- }
- }
- class Airmelon extends Melon {
- constructor(weight, melonSort) {
- super(weight, melonSort);
- }
- }
- class Firemelon extends Melon {
- constructor(weight, melonSort) {
- super(weight, melonSort);
- }
- }
- class Earthmelon extends Melon {
- constructor(weight, melonSort) {
- super(weight, melonSort);
- }
- }
- class Melolemonmelon extends Watermelon {
- constructor(weight, melonSort) {
- super(weight, melonSort);
- }
- morph() {
- let changer = state.shift();
- state.push(changer);
- }
- }
- return { Melon, Watermelon, Firemelon, Earthmelon, Airmelon, Melolemonmelon };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement