Advertisement
divanov94

Untitled

Oct 16th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solution() {
  2.     class Hall {
  3.         constructor(capacity, name) {
  4.             this.capacity = capacity;
  5.             this.name = name;
  6.             this.events = [];
  7.         }
  8.  
  9.         hallEvent(title) {
  10.             if (!this.events.includes(title)) {
  11.                 this.events.push(title);
  12.                 return 'Event is added.'
  13.             }else {
  14.                 throw new Error('This event is already added!');
  15.             }
  16.  
  17.         }
  18.         close(){
  19.             this.events=[];
  20.             return `${this.name} hall is closed`;
  21.         }
  22.         toString(){
  23.             let output=[];
  24.             output.push(`${this.name} hall - ${this.capacity}`);
  25.             if(this.events.length>0){
  26.                 output.push(`Events: ${this.events.join(", ")}`);
  27.             }
  28.             return output.join('\n');
  29.         }
  30.     }
  31.     class MovieTheater extends Hall{
  32.         constructor(capacity,name,screenSize) {
  33.             super(capacity,name);
  34.             this.events=[];
  35.             this.screenSize=screenSize;
  36.         }
  37.         close(){
  38.             return `${super.close()}All screenings are over.`
  39.         }
  40.         toString() {
  41.             return `${super.toString()}\n${this.name} is a movie theather with ${this.screenSize} screensize and ${this.capacity} seats capacity.`;
  42.  
  43.         }
  44.  
  45.     }
  46.     class ConcertHall extends Hall{
  47.         constructor(capacity,name){
  48.             super(capacity,name);
  49.             this.events=[];
  50.         }
  51.         //hallEvents(title,performers){
  52.  
  53.  
  54.             if(this.events.find(e=>e.title===title)!==undefined){
  55.                 throw new Error('This event is already added!');
  56.             }else {
  57.                this.events.push([performers]);
  58.                 return `Event is added.`
  59.             }
  60.  
  61.  
  62.         }
  63.         close(){
  64.             return `${super.close()} All performances are over.`
  65.         }
  66.         toString() {
  67.             let output=[
  68.                 super.toString(),
  69.             ];
  70.             if(this.events.length>0){
  71.                 output.push('Performers:');
  72.                 this.events.forEach(e=>output.push('dsd'))
  73.  
  74.             }
  75.  
  76.         }
  77.     }
  78.  
  79.  
  80.     return {
  81.         Hall,
  82.         MovieTheater,
  83.         ConcertHall,
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement