jizzm.JS

fukurou

the supreme coder
ADMIN
livingrimoire.js
JavaScript:
// livingrimoire.js

class AbsDictionaryDB {
    save(key, value) {
        // Save to DB (override me)
    }

    load(key) {
        // Override me
        return "null";
    }
}

class Mutatable {
    constructor() {
        this.algKillSwitch = false;
    }

    // Abstract methods (to be overridden by subclasses)
    Action(ear, skin, eye) {
        throw new Error('Action method must be overridden');
    }

    Completed() {
        throw new Error('Completed method must be overridden');
    }

    MyName() {
        // Returns the class name
        return this.constructor.name;
    }
}

module.exports = { AbsDictionaryDB, Mutatable };
main (app.js)

JavaScript:
// app.js
const readline = require('readline');
const { AbsDictionaryDB, Mutatable } = require('./livingrimoire');

// Create an instance of AbsDictionaryDB
const db = new AbsDictionaryDB();

// Test the save and load methods
db.save('key1', 'value1');
const value = db.load('key1');
console.log(`Loaded value: ${value}`);

// Create a subclass of Mutatable to test abstract methods
class MyMutatable extends Mutatable {
    Action(ear, skin, eye) {
        return `Action performed with ${ear}, ${skin}, and ${eye}`;
    }

    Completed() {
        return true;
    }
}

const myMutatable = new MyMutatable();
console.log(myMutatable.MyName());
console.log(myMutatable.Action('ear1', 'skin1', 'eye1'));
console.log(`Completed: ${myMutatable.Completed()}`);

// Keep the console open
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question('Press Enter to exit...', () => {
    rl.close();
});
 

owly

闇の伝説
Staff member
戦闘 コーダー
  1. AbsDictionaryDB +
  2. Mutatable +
  3. APVerbatim:Mutatable +
  4. GrimoireMemento +
  5. Algorithm+
  6. Kokoro+
  7. Neuron+
  8. Skill+
  9. DiHelloWorld:Skill // logical skill for testing+
  10. Cerabellum+
  11. Fusion+
  12. Chobits+
  13. Brain+
  14. DiSysOut:Skill // hardware skill for testing+
 
Last edited:
Top