Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution() {
- class Hall {
- constructor(capacity, name) {
- this.capacity = capacity;
- this.name = name;
- this.events = [];
- }
- hallEvent(title) {
- if (!this.events.includes(title)) {
- this.events.push(title);
- return 'Event is added.'
- }else {
- throw new Error('This event is already added!');
- }
- }
- close(){
- this.events=[];
- return `${this.name} hall is closed`;
- }
- toString(){
- let output=[];
- output.push(`${this.name} hall - ${this.capacity}`);
- if(this.events.length>0){
- output.push(`Events: ${this.events.join(", ")}`);
- }
- return output.join('\n');
- }
- }
- class MovieTheater extends Hall{
- constructor(capacity,name,screenSize) {
- super(capacity,name);
- this.events=[];
- this.screenSize=screenSize;
- }
- close(){
- return `${super.close()}All screenings are over.`
- }
- toString() {
- return `${super.toString()}\n${this.name} is a movie theather with ${this.screenSize} screensize and ${this.capacity} seats capacity.`;
- }
- }
- class ConcertHall extends Hall{
- constructor(capacity,name){
- super(capacity,name);
- this.events=[];
- }
- //hallEvents(title,performers){
- if(this.events.find(e=>e.title===title)!==undefined){
- throw new Error('This event is already added!');
- }else {
- this.events.push([performers]);
- return `Event is added.`
- }
- }
- close(){
- return `${super.close()} All performances are over.`
- }
- toString() {
- let output=[
- super.toString(),
- ];
- if(this.events.length>0){
- output.push('Performers:');
- this.events.forEach(e=>output.push('dsd'))
- }
- }
- }
- return {
- Hall,
- MovieTheater,
- ConcertHall,
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement