Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with this JAVASCRIPT program, please? Class and Constructor

ID: 3797304 • Letter: C

Question

Can someone help me with this JAVASCRIPT program, please?

Class and Constructor Creation

    Book Class

        Create a script called library.js. In this file create a constructor function for a Book object. The Book object should have the following properties:

        Title

        Available: Boolean representing whether the book is checked out or not. The initial value should be false.

        Publication Date: Use a date object

        Checkout Date: Use a date object

        Call Number: Make one up

        Authors: Should be an array of Author objects

    Author Class

        Create a constructor function for an object called Author. It should have a property for the first name and last name of the author.

    Patron Class

       Create a constructor function for an object called Patron. This represents a person who is allowed to check out books from the library.

       Give it the following properties:

        Firstname

        Lastname

        Library Card Number (Make one up)

        Books Out: Make it an array

        fine: Starts a 0.00

B. Methods to add

    Book Class

       Add a function to the Book prototype called "checkOut". The function will change the available property of the book from true to false and set the checkout date. The

       checkout date should be set to the current date minus some random number of days.

       Add a function to the Book prototype called "checkIn". The function will change the available property of the book from false to true.

       Add a function called isOverdue that checks the current date and the checked out date and if it's greater than 14 days it returns true

    Patron Class

       Add a function to the Patron prototype called "read" that adds a book to it's books out property.

      Add a function to the Patron prototype called "return" that removes a book from it's books out property.

C. Test Program

    Create 5 different books from the Book Class and store them in an array called catalog.

    Create 5 different patrons from the Patron Class and store them in an array called patrons.

    Write a loop that simulates checkouts and checkins for a 3 month period. Every day iterate over the catalog, and every person in the patrons array. If the patron        
    currently has the book checked out then check it in. If it is not checked out then add it to the patrons list of books via the patrons read method. If the book is overdue  
    then add a fine of $5.00 to the patron returning it. At the end of the 3 month period, display each patron, the books they have currently checked out and any fine they
    may have.

Explanation / Answer

Hello there,

I am providing a combined solution for all the three parts of the problem. The program written below is well commented and it should help you understand the solution. :

(The simulation bit is extremely confusing and unclear. I have not completed that bit, but I have written most of the program that should help you understand the concept thoroughly. I could have completed it, but it would require adding a ton of code which has not been asked. My solution should help you with the concepts atleast.)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote