Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- class Fighter {
- constructor(name) {
- this.name = name;
- this.health = 100;
- this.stamina = 100;
- }
- fight() {
- this.stamina--;
- console.log(`${this.name} slashes at the foe!`);
- }
- }
- class Mage {
- constructor(name) {
- this.name = name;
- this.health = 100;
- this.mana = 100;
- }
- cast(spell) {
- this.mana--;
- console.log(`${this.name} cast ${spell}`);
- }
- }
- const Obj = {
- mage: (name)=> new Mage(name),
- fighter: (name) => new Fighter(name),
- };
- return Obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement