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