Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Class and Constructor Creation
  2.  
  3. Book Class
  4.  
  5. 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:
  6.  
  7. Title
  8.  
  9. Available: Boolean representing whether the book is checked out or not. The initial value should be false.
  10.  
  11. Publication Date: Use a date object
  12. Checkout Date: Use a date object
  13.  
  14. Call Number: Make one up
  15.  
  16. Authors: Should be an array of Author objects
  17.  
  18. Author Class
  19.  
  20. Create a constructor function for an object called Author. It should have a property for the first name and last name of the author.
  21.  
  22. Patron Class
  23.  
  24. Create a constructor function for an object called Patron. This represents a person who is allowed to check out books from the library.
  25.  
  26. Give it the following properties:
  27.  
  28. Firstname
  29.  
  30. Lastname
  31.  
  32. Library Card Number (Make one up)
  33.  
  34. Books Out: Make it an array
  35.  
  36. fine: Starts a 0.00
  37.  
  38. B. Methods to add
  39.  
  40. Book Class
  41.  
  42. 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
  43.  
  44. checkout date should be set to the current date minus some random number of days.
  45.  
  46. Add a function to the Book prototype called "checkIn". The function will change the available property of the book from false to true.
  47.  
  48. 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
  49.  
  50. Patron Class
  51.  
  52. Add a function to the Patron prototype called "read" that adds a book to it's books out property.
  53.  
  54. Add a function to the Patron prototype called "return" that removes a book from it's books out property.
  55.  
  56. C. Test Program
  57.  
  58. Create 5 different books from the Book Class and store them in an array called catalog.
  59.  
  60. Create 5 different patrons from the Patron Class and store them in an array called patrons.
  61.  
  62. 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
  63. 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
  64. 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
  65. may have.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement