diff --git a/classes/Book.js b/classes/Book.js index ee69d54..39e6526 100644 --- a/classes/Book.js +++ b/classes/Book.js @@ -1,6 +1,28 @@ // import the Media class: +const Media = require('./Media') // create your Book class: +class Book extends Media { + constructor(author, numPages, rating){ + this.author = author; + this.numPages = numPages; + this.rating = rating; + super(title); + super(year); + super(this.genre); + } + summary(){ + return `Title: ${this.title}, Author: ${author}, Year: ${this.year}, Page Count: ${this.numPages}, Genre: ${this.genre}, Rating: ${this.rating}` + } + static highestRating (){ + highest = Media.rating[0] + for (i = 0; i < Media.rating.length; i++){ + if (Media.rating[i] > highest ){ + highest = Media.rating[i] + } + } + } +} // don't change below module.exports = Book; diff --git a/classes/Media.js b/classes/Media.js index d4d718b..9978606 100644 --- a/classes/Media.js +++ b/classes/Media.js @@ -1,4 +1,15 @@ -// create your Media class: +class Media { + static totalMediaCount = 0; + constructor(title, year, genre){ + this.title = title; + this.year = year; + this.genre = genre; + Media.totalMediaCount += 1; + } + + summary(){ + return `Title: ${this.title}, Year: ${this.year}, Genre: ${this.genre}` + } +} -// uncomment below to export it: -module.exports = Media; +module.exports = Media diff --git a/classes/Movie.js b/classes/Movie.js index 484e7a3..b9935ed 100644 --- a/classes/Movie.js +++ b/classes/Movie.js @@ -1,6 +1,11 @@ // import the Media class: - +const Media = require('./classes/Media') // create your Movie class: +class Movie extends Media { + constructor(){ + + } +} // don't change below module.exports = Movie; \ No newline at end of file diff --git a/main.js b/main.js index 102baa9..5192789 100644 --- a/main.js +++ b/main.js @@ -1 +1,9 @@ // Import classes here to console.log and debug +const Media = require('./classes/Media') +const Book = require('./classes/Book') + +const newmedia = new Media('title',1998, 'genre'); +const new2 = new Media('title2', 1988, 'genre2'); +//const new3 = new Media('title3', 1988, 'genre3') +//console.log(Media.count); +console.log(Media.totalMediaCount()); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 47c194a..55202d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4717,7 +4717,8 @@ "jest-pnp-resolver": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", - "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==" + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "requires": {} }, "jest-regex-util": { "version": "29.4.3",