Q2. Book Donation App You are required to develop a Book Donation App that allows people to donate books. The book donation system should have the following classes a) Book – bookId, title, author, imageUrl, donorId, status DonorId property is should hold , the ID of the person who donated the book. Note that the status attribute can have one of the following values: - pending : As soon as the user adds a donated book to the system, the status is set to pending. - available : When the book donor delivered the book to the store then status of the book can be changed to available. b) Donor - donorId, firstname , lastname , phone, street, city, email, password c) BookCatalog – contains list of books and a list of donors. Also the class contains the following methods addBook(book) Adds a book to the list of books (the status of newly added boom should be set to pending). updateBook(book) Updates the book having the matching bookId. deleteBook(bookId) Deletes the book from the list of books. getBooks(status=available) Returns the books by status. By default, only available books should be return. getDonorBooks(donorId) Returns the books donated by a particular donor. getTopDonors(topCount) Returns the top book donors. Eg. If the user passes 3 as topCount parameter, then this function returns the top 3 donors and the list of books each one has donated. addDonor Add new donor to the list of donors updateDonor(donorId) allow the user to update the donor details deleteDonor(donorId) You can delete a donor, if they are not associated with any book Test your code by creating app.js file to instantiate the BookCatalog class and test its methods. Note that you should make use of the JavaScript features and capabilities such as arrow functions, array functions (.map, .reduce, .filter, .splice, .sort…), spread operator, object literals, and classes.
****using javascript****
Q2. Book Donation App
You are required to develop a Book Donation App that allows people to donate books.
The book donation system should have the following classes
a) Book – bookId, title, author, imageUrl, donorId, status
DonorId property is should hold , the ID of the person who donated the book.
Note that the status attribute can have one of the following values:
- pending : As soon as the user adds a donated book to the system, the status is set
to pending.
- available : When the book donor delivered the book to the store then status of the
book can be changed to available.
b) Donor - donorId, firstname , lastname , phone, street, city, email, password
c) BookCatalog – contains list of books and a list of donors. Also the class contains the
following methods
addBook(book) Adds a book to the list of books (the status of newly added
boom should be set to pending).
updateBook(book) Updates the book having the matching bookId.
deleteBook(bookId) Deletes the book from the list of books.
getBooks(status=available) Returns the books by status. By default, only available books
should be return.
getDonorBooks(donorId) Returns the books donated by a particular donor.
getTopDonors(topCount) Returns the top book donors. Eg. If the user passes 3 as
topCount parameter, then this function returns the top 3 donors
and the list of books each one has donated.
addDonor Add new donor to the list of donors
updateDonor(donorId) allow the user to update the donor details
deleteDonor(donorId) You can delete a donor, if they are not associated with any
book
Test your code by creating app.js file to instantiate the BookCatalog class and test its methods.
Note that you should make use of the JavaScript features and capabilities such as arrow
functions, array functions (.map, .reduce, .filter, .splice, .sort…), spread operator, object
literals, and classes.
Step by step
Solved in 2 steps