Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. class Animal {
  2. constructor(type) {
  3. this.type = type;
  4. }
  5. say(message) {
  6. return `${this.name} says ${message}`;
  7. }
  8. attack(animal) {
  9. return `${this.name} is attacking ${animal.name}, wtf?`;
  10. }
  11. }
  12.  
  13. class Monkey extends Animal {
  14. constructor(name, age) {
  15. super();
  16. this.type = "Monkey";
  17. this.name = name;
  18. this.age = age;
  19. }
  20. }
  21.  
  22. class DonkeyKong extends Monkey {
  23. constructor(name, age) {
  24. super();
  25. this.name = name;
  26. this.age = age;
  27. }
  28. yeet() {
  29. return `${this.name} is yeeting really bad.`;
  30. }
  31. }
  32.  
  33. class Fish extends Animal {
  34. constructor(name, age) {
  35. super();
  36. this.type = "Fish";
  37. this.name = name;
  38. this.age = age;
  39. }
  40. bloop() {
  41. return `I think ${this.name} is drowning...`;
  42. }
  43. }
  44.  
  45. const Monk = new Monkey("George", 10);
  46. const Fishy = new Fish("Stewart", 12);
  47. const Donkey = new DonkeyKong("Oof", 400);
  48. console.log(Donkey);
  49. console.log(Fishy);
  50. console.log(Monk);
  51.  
  52. console.log(Donkey.say("Yeet my boi"));
  53. console.log(Donkey.yeet());
  54. console.log(Fishy.say("Wassup"));
  55. console.log(Fishy.bloop());
  56. console.log(Fishy.attack(Donkey));
  57. console.log(Monk.say("Zoboomafoo"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement