Build a Library

class Media {
constructor(title){
this._title = title;
this._isCheckedOut = false;
this._ratings = ;
}

  get title(){
       return this._title; 
  }

  get isCheckedOut(){
       return this._isCheckedOut;
  }

  get ratings(){
       return this._ratings;
  }

  set isCheckedOut(value){
      this._isCheckedOut = value;
  }

  toggleCheckOutStatus(){
       this._isCheckedOut = !this._isCheckedOut;
  } 
  
  getAverageRating(){
       const sumRatings = this._ratings.reduce((accumulator,currentValue) => accumulator + currentValue, 0);
       return Math.floor(sumRatings / this._ratings.length); 
  }

  addRating(value){
         if(value >= 1 && value <= 5){
           this._ratings.push(value);
         } else {
           return 'the input must not be less than one and not more than five.';
         }
  } 

}

class Book extends Media{
constructor(author, title, pages){
super(title);
this._author = author;
this._pages = pages;
}

    get author(){
        return this._author;
    }

    get pages(){
        return this._pages;
    }

}

class Movie extends Media{
constructor(director, title, runTime){
super(title);
this._director = director;
this._runTime = runTime;
this._movieCast = ;
}

    get director(){
           return this._director;
    }

    get runTime(){
           return this._runTime;
    }

    get movieCast(){
           return this._movieCast;
    }

    addMovieCast(value){
           this._movieCast.push(value);
    }

}

const historyOfEverything = new Book(‘Bill Bryson’, ‘A Short History of Nearly Everything’, 544);

const speed = new Movie(‘Jan de Bont’, ‘Speed’, 116);

class CD extends Media{
constructor(artist, title){
super(title);
this._artist = artist;
this._songTitles = ;
}

     get artist(){
           return this._artist;
     }

     get songTitles(){
         return this._songTitles;
     }

     addSongs(value){
         this._songTitles.push(value);
     }

     shuffle(){
          return this._songTitles.sort(()=> 0.5 - Math.random());        
     }

}

const songTitlesVuelveALlamar = new CD(‘Jesus Adrian Romero’, ‘Ayer Te Vi’);

class Catalog {

   static book(){
       console.log(historyOfEverything.author);
       console.log(historyOfEverything.title);
       console.log(historyOfEverything.pages);
       historyOfEverything.toggleCheckOutStatus();
       console.log(historyOfEverything.isCheckedOut);
       historyOfEverything.addRating(4);
       historyOfEverything.addRating(5);
       historyOfEverything.addRating(5);
       console.log(historyOfEverything.getAverageRating());
   }

   static movie(){
       console.log(speed.director);
       console.log(speed.title);
       console.log(speed.runTime);
       speed.addMovieCast('Keanu Reeves');
       speed.addMovieCast('Dennis Hopper');
       speed.addMovieCast('Sandra Bullock');
       speed.addMovieCast('Joe Morton');
       speed.addMovieCast('Jeff Daniels');
       speed.addMovieCast('Alan Ruck');
       speed.addMovieCast('Glenn Plummer');
       speed.addMovieCast('Beth Grant');
       console.log(speed.movieCast);
       speed.toggleCheckOutStatus();
       console.log(speed.isCheckedOut);
       speed.addRating(1);
       speed.addRating(1);
       speed.addRating(5);
       console.log(speed.getAverageRating());
   }

   static CD(){
       console.log(songTitlesVuelveALlamar.artist);
       console.log(songTitlesVuelveALlamar.title);
       songTitlesVuelveALlamar.addSongs('Vuelve a LLamar');
       songTitlesVuelveALlamar.addSongs('Que Seas Mi Hogar');
       songTitlesVuelveALlamar.addSongs('Como La Brisa');
       songTitlesVuelveALlamar.addSongs('Mi Día');
       songTitlesVuelveALlamar.addSongs('No Hay Paredes');
       console.log(songTitlesVuelveALlamar.songTitles);
       console.log(songTitlesVuelveALlamar.shuffle()); 
   }

}

Catalog.book();
Catalog.movie();
Catalog.CD();