diff --git a/classes/Book.js b/classes/Book.js index ee69d54..4ff8cb2 100644 --- a/classes/Book.js +++ b/classes/Book.js @@ -1,6 +1,26 @@ // import the Media class: - +const Media = require("./Media"); // create your Book class: - +class Book extends Media { + constructor(title, year, genre, author, numpages, rating) { + super(title, year, genre); + this.author = author; + this.numpages = numpages; + this.rating = rating; + } + summary() { + return `Title: ${this.title}, Author: ${this.author}, Year: ${this.year}, Page Count: ${this.numpages}, Genre: ${this.genre}, Rating: ${this.rating}`; + } + static highestRating(Book) { + let highestRatedBook = Book[0]; + for (let i = 0; i < highestRatedBook.rating; i++) { + if (Book[i].rating > highestRatedBook.rating) { + highestRatedBook = Book[i]; + } + } + return highestRatedBook; + } +} // don't change below module.exports = Book; + diff --git a/classes/Media.js b/classes/Media.js index d4d718b..eb7c363 100644 --- a/classes/Media.js +++ b/classes/Media.js @@ -1,4 +1,19 @@ // create your Media class: +// create your Media class: +class Media { + static totalMediaCount = 0; + constructor(title, year, genre) { + this.title = title; + this.year = year; + this.genre = genre; + Media.totalMediaCount++; + } + summary() { + return `Title: ${this.title}, Year: ${this.year}, Genre: ${this.genre}`; + } +} +// uncomment below to export it: +module.exports = Media; // uncomment below to export it: module.exports = Media;