You're building a virtual library app, and you need to create a set of classes to represent different types of media. You'll have books, movies, and music, each with their own unique properties. You'll need to create a base class for all media, and several subclasses for specific types of media. You'll also need to create a static method to keep track of the total number of media items in the library.
- You can run any of the files with the command
node PATH_TO_FILE. - To run the tests, do the following in the root folder of this project:
npm install
npm testUnderlined items are static method. Italicized items are static properties
- In
Media.js, create aMediaclass. TheMediaclass should have the following properties and methods:title: the title of the media (string)year: the year the media was produced (number)genre: the genre of the media (string)totalMediaCount: A static property that tracks how many Media items have been createdsummary(): a method that returns a summary of the media (string) as"Title: <TITTLE>, Year: <YEAR>, Genre: <GENRE>"
- Export the
Mediaclass usingmodule.exports. - In
index.js, importMediausingrequire.
const book = new Media('The Catcher in the Rye', 1951, 'Fiction');
Media.totalMediaCount; // 1
const music = new Media('Abbey Road', 1969, 'Rock');
Media.totalMediaCount; // 2
music.summary(); // "Title: Abbey Road, Year: 1969, Genre: Rock"- In
Book.js, create aBookclass. TheBookclass should be a subclass ofMedia. ImportMediainto theBook.jsfile usingrequire. Bookshould have the following properties and methods:author: the author of the book (string)numPages: the number of pages in the book (number)rating: the average rating of the book (number between 1-5)summary(): a method that returns a summary of the book, including the author, number of pages, and rating (string) as"Title: <TITTLE>, Author: <AUTHOR>, Year: <YEAR>, Page Count: <NUM_PAGES>, Genre: <GENRE>, Rating: <RATING>"
- The
Bookclass should have a static methodhighestRatingthat takes an array ofBookitems and returns theBookwith the highest rating. - Export the
Bookclass usingmodule.exports. - In
index.js, importBookusingrequire.
const book1 = new Book('To Kill a Mockingbird', 1960, 'Fiction', 'Harper Lee', 281, 4.4);
Media.totalMediaCount; // 1
const book2 = new Book('The Bluest Eye', 1970, 'Fiction', 'Toni Morrison', 206, 4.6);
Media.totalMediaCount; // 2
book1.summary(); // "Title: To Kill a Mockingbird, Author: Harper Lee, Year: 1960, Page Count: 281, Genre: Fiction, Rating: 4.4"
Book.highestRating([book1, book2]); // Returns book2- In
Movie.js, create aMovieclass. TheMovieclass should be a subclass ofMedia. ImportMediainto theMovie.jsfile usingrequire. Musicshould have the following properties and methods:director: the director of the movie (string)duration: the duration of the movie in minutes (number)rating: the average rating of the movie (number between 1-5)summary(): a method that returns a summary of the movie, including the director, duration, and rating (string) as"Title: <TITTLE>, Director: <DIRECTOR>, Year: <YEAR>, Genre: <GENRE>, Duration: <DURATION>, Rating: <RATING>"
- The
Movieclass should have a static methodlongestMoviethat takes an array ofMovieobjects and returns theMoviewith the longest duration. - Export the
Movieclass usingmodule.exports. - In
index.js, importMovieusingrequire.
const movie1 = new Movie('Inception', 2010, 'Sci-Fi', 'Christopher Nolan', 148, 4.5);
const movie2 = new Movie('The Godfather', 1972, 'Crime', 'Francis Ford Coppola', 175, 4.7);
Media.totalMediaCount; // 2
movie1.summary(); // "Title: Inception, Director: Christopher Nolan, Year: 2010, Genre: Sci-Fi, Rating: 4.5"
Movie.longestMovie([movie1, movie2]); // Returns movie2- In
Music.js, create aMusicclass. TheMusicclass should be a subclass ofMedia. ImportMediainto theMusic.jsfile usingrequire. Musicshould have the following properties and methods:artist: the artist of the music (string)length: the length of the music in seconds (number)summary(): a method that returns a summary of the music, including the artist, album, and length (string) as"Title: <TITTLE>, Artist: <ARTIST>, Year: <YEAR>, Genre: <GENRE>, Length: <LENGTH>"
- The
Musicclass should have a static methodshortestAlbumthat takes an array ofMusicobjects and returns theMusicobject with the shortest song length. - Export the
Musicclass usingmodule.exports. - In
index.js, importMusicusingrequire.
const music1 = new Music('Lemonade', 2016, 'R&B', 'Beyonce', 'Lemonade', 3949);
const music2 = new Music('Renaissance', 2022, 'R&B', 'Beyonce', 'Beyonce', 3734);
Media.totalMediaCount; // 2
music2.summary(); // "Title: Renaissance, Artist: Beyonce, Year: 2022, Genre: R&B, Length: 3734 seconds"
Music.shortestAlbum([music1, music2]); // Returns music2- Create a class of
Podcastthat is a subclass ofMusic.Podcastshould inherit all of the properties and methods from theMusicclass and have an additional properties and methods of:host: A string with the name of the host.episodeName: A string with the name of the episodeepisodeNumber: A number with the episode number.guests: An array of the guests on the particular episode.listen(): Methods that returns the string<TITLE> - Episode: <EPISODE_TITLE>. Hosted by <HOST> and featuring guests <GUESTS>. Length: <LENGTH> seconds.
- Add a static method to
BookandMoviecalledcalculateAverageRating(): This should accept an array ofBookorMovieobjects and return the average rating for these objects. - In
Mediacreate a static property ofALL_MEDIA. This should be an array that contains allMediaobjects created using the class.

