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