Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rat {
- constructor(name){
- this.name = name;
- this.unitedRats = [];
- }
- unite(otherRat) {
- if (otherRat instanceof Rat){
- this.unitedRats.push(otherRat);
- }
- }
- getRats() {
- return this.unitedRats;
- }
- toString() {
- return `${this.name}\n${this.unitedRats.map(r=>`##${r}`).join('')}`
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement