Question: I'm going to write a computer science home. Trying to get some help. Also, need some help with test code.Here is the requirement. The Book
I'm going to write a computer science home. Trying to get some help. Also, need some help with test code.Here is the requirement.
The Book constructor will be used to initialize all attributes of the Book object. The initial status of the book should be AVAILABLE, and the patron and due date should be null.
Like the constructor, the checkin method should set the book's status to AVAILABLE and assign null to both patron and due date.
The checkout method should make the book UNAVAILABLE and save the given patron and due date in the object.
The equals method checks whether two books have the same isbn. If the given object is a Book, compare this.isbn with the other book's isbn. If the given object is a String, compare this.isbn with the string.
In the UML diagram, getX is actually eight methods: one accessor method for each of the eight attributes. These should be easy to implement (Eclipse will generate them automatically). Note that the class should have no "setX" methods.
The toString method should return a String representation of the book. If a book is initialized with the following parameters ("aaa", "bbb", "1234BBBBBBBBB", 2013, 10), it should return a String exactly as follows: "Title: aaa, Author: bbb, ISBN: 1234BBBBBBBBB, Year: 2013, Pages: 10."
Patron.java
The Patron constructor will be used to initialize all attributes of the Patron object.
The adjustBalance will update the current balance of the patron. For example if the current balance of a Patron is 2.0 and the amount is 4.5, this method should assign 6.50 to this.balance and return 6.50.
The equals method checks whether two patrons have the same id number. If the given object is a Patron, compare this.idNumber with the other patron's idNumber. If the given object is an Integer, compare this.idNumber with the Integer.
The toString method should return a String representation of the Patron. If a patron is initialized with the following parameters ("bob", "eee", 2, 5.5), it should return a String exactly as follows: "Name: bob, Email: eee, ID: 2, Balance: $5.50."
Library.java
The Library constructor will initialize an array of Book and Patron objects using the book and patron array parameters.
The checkin method will check in a book upon return. If the returned book belongs in the Library, and it is currently checked out, this method should update the status of the book, reset its patron and due date, determine the fine for this book (if any), and update the patron's balance. The return value indicates success or failure. For example, if the book is not in the library, checkin should return false.
The checkout method will let a patron checkout a book that is available in the Library. If the book belongs to the library and is available, this method will update it's status and patron, and set the due date to ten days from today's date. The return value indicates success or failure. For example, if the book is not in the library, checkout should return false.
The determineFine method will compute the fine currently due for a book that is checked out. For this method, the fine rate is $0.50 per day for each day after the due date.
The searchBooks method searches for books, depending on the key and type, and returns an array of the books found. If no books are found, the resulting array will have a length of zero.
When type is TITLE_SEARCH, key will be a string containing the title to search. The method should return all books with that title.
When type is AUTHOR_SEARCH, key will be a String containing the author's name. The method should return all books for that author.
When type is PATRON_SEARCH, key will either be a Patron object or an Integer with the Patron's id. The method should return all books checked out to that patron.
When type is OVERDUE_SEARCH, key will be a Date object. The method should return all books that will be overdue on that date (if not checked in before then).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
