Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions classes/Book.js
Original file line number Diff line number Diff line change
@@ -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;

15 changes: 15 additions & 0 deletions classes/Media.js
Original file line number Diff line number Diff line change
@@ -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;