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
29 changes: 28 additions & 1 deletion classes/Book.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
// 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 < book.length; i++) {
let rating = book[i].rating

if (rating > highestRatedBook.rating) {
highestRatedBook = book[i]
}
}

return highestRatedBook
}
}

// don't change below
module.exports = Book;
16 changes: 16 additions & 0 deletions classes/Media.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
// create your Media class:

class Media {

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}`)
}
}

Media.totalMediaCount = 0

// uncomment below to export it:
module.exports = Media;
28 changes: 28 additions & 0 deletions classes/Movie.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// import the Media class:
const Media = require('./Media')

// create your Movie class:

class Movie extends Media {
constructor(title, year, genre, director, duration, rating) {
super(title, year, genre)
this.director = director
this.duration = duration
this.rating = rating
}

summary(){
return (`Title: ${this.title}, Director: ${this.director}, Year: ${this.year}, Genre: ${this.genre}, Rating: ${this.rating}`)
}

static longestMovie(movies) {
let longestMovieObject = movies[0]

for(let i = 0; i < movies.length; i++) {
let duration = movies[i].duration

if (duration > longestMovieObject.duration) {
longestMovieObject = movies[i]
}
}

return longestMovieObject
}
}

// don't change below
module.exports = Movie;
28 changes: 28 additions & 0 deletions classes/Music.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// import the Media class:
const Media = require('./Media')

// create your Music class:

class Music extends Media {
constructor(title, year, genre, artist, length) {
super(title, year, genre)
this.artist = artist
this.length = length
}

summary(){
return (`Title: ${this.title}, Artist: ${this.artist}, Year: ${this.year}, Genre: ${this.genre}, Length: ${this.length} seconds`)
}


static shortestAlbum(albums) {
let shortestAlbumObj = albums[0]

for(let i = 0; i < albums.length; i++) {
let songLength = albums[i].length

if (songLength < shortestAlbumObj.length) {
shortestAlbumObj = albums[i]
}
}

return shortestAlbumObj
}
}

// don't change below
module.exports = Music;
3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Import classes here to console.log and debug
const Media = require('./classes/Media')
const Book = require('./classes/Book')
const Movie = require('./classes/Movie')
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.