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