As previous tasks it uses yarn
and jest
testing framework so the process is the same:
git clone
the repo.- Create new
branch
with your name and checkout. - Run
yarn
. - To run tests: run
yarn test
oryarn watch
depending on your preference.
Congratulations, you’ve passed the grueling rigmarole of librarian school and have become head librarian at your local Books-‘N-Stuff.
Just as you sit down, eager to utilize all those skills you learned in “Lib 203 - Shushing: How to Maintain Order While Spitting”, you realize you’re still using index cards to handle everything.
But no matter, you know some JavaScript, so let’s get to work modernizing your new digs.
Books-‘N-Stuff carries three different types of media: books, CDs, and movies. In this project you will create a parent class named Media
with three subclasses: Book
, Movie
, and CD
. These three subclasses have the following properties and methods:
Properties:
author
: stringtitle
: stringpages
: numberisCheckedOut
: boolean, initially falseratings
: array, initially empty
Getters: all properties have a getter
Methods:
.getAverageRating()
.toggleCheckOutStatus()
.addRating()
Properties:
director
: stringtitle
: stringrunTime
: numberisCheckedOut
: boolean, initially falseratings
: array, initially empty
Getters: all properties have a getter
Methods:
.getAverageRating()
.toggleCheckOutStatus()
.addRating()
Properties:
artist
: stringtitle
: stringisCheckedOut
: boolean, initially falseratings
: array, initially emptysongs
: array of strings
Getters: all properties have a getter
Methods:
.getAverageRating()
.toggleCheckOutStatus()
.addRating()
After you implemented each of them in resources.js
, inside index.js
:
- create an object at least from one of the class type
console.log
each getter's value- test each method's behavior