Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Animal {
- constructor(type) {
- this.type = type;
- }
- say(message) {
- return `${this.name} says ${message}`;
- }
- attack(animal) {
- return `${this.name} is attacking ${animal.name}, wtf?`;
- }
- }
- class Monkey extends Animal {
- constructor(name, age) {
- super();
- this.type = "Monkey";
- this.name = name;
- this.age = age;
- }
- }
- class DonkeyKong extends Monkey {
- constructor(name, age) {
- super();
- this.name = name;
- this.age = age;
- }
- yeet() {
- return `${this.name} is yeeting really bad.`;
- }
- }
- class Fish extends Animal {
- constructor(name, age) {
- super();
- this.type = "Fish";
- this.name = name;
- this.age = age;
- }
- bloop() {
- return `I think ${this.name} is drowning...`;
- }
- }
- const Monk = new Monkey("George", 10);
- const Fishy = new Fish("Stewart", 12);
- const Donkey = new DonkeyKong("Oof", 400);
- console.log(Donkey);
- console.log(Fishy);
- console.log(Monk);
- console.log(Donkey.say("Yeet my boi"));
- console.log(Donkey.yeet());
- console.log(Fishy.say("Wassup"));
- console.log(Fishy.bloop());
- console.log(Fishy.attack(Donkey));
- console.log(Monk.say("Zoboomafoo"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement