Advertisement
kstoyanov

05. Unity

Sep 23rd, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Rat {
  2.   constructor(name) {
  3.     this.name = name;
  4.     this.rats = [];
  5.   }
  6.  
  7.   getRats() {
  8.     return this.rats;
  9.   }
  10.  
  11.   unite(otherRat) {
  12.     return otherRat.constructor.name === this.constructor.name && this.rats.push(otherRat);
  13.   }
  14.  
  15.   toString() {
  16.     return this.name;
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement