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

We are now going to write a class to represent a LibraryBook. You will implement

ID: 645418 • Letter: W

Question

We are now going to write a class to represent a LibraryBook. You will implement the following API in your class:

Constructor

The constructor should set title and author based on the provided arguments, set checkedOut to false, set daysUntilDue to 0, and set whoCheckedOut to the empty string.

checkOut(String whoCheckedOut)

The checkOut(String whoCheckedOut) method should first check to see if the book is already checked out by looking at the value of checkedOut.

-If the book is already checked out, return false to indicate the book could not successfully be checked out.

-If the book is not already checked out, set checkedOut to true, set daysUntilDue to 14 (two weeks), set whoCheckedOut to the given parameter, and return true to indicate the book was successfully checked out.

advanceDay()

The advanceDay() method should first check to see if the book is already checked out by looking at the value of checkedOut.

- If the book is checked out, the advanceDay() method should subtract one from daysUntilDue.

-If daysUntilDue is now 0, set checkedOut to false and whoCheckedOutto the empty string, and return true.

-If daysUntilDue is greater than 0, return false.

-If the book is not checked out, return false.

toString()

If the book is not checked out, the toString() method will return a string in the format

LibraryBook ? title : String
? author : String
? checkedOut : boolean
? daysUntilDue : int
? whoCheckedOut : String + LibraryBook(title: String, author: String)
+ setTitle(title: String) : void
+ getTitle() : String
+ setAuthor(author: String) : void
+ getAuthor() : String
+ isCheckedOut() : boolean
+ getDaysUntilDue() : int
+ getWhoCheckedOut() : String
+ checkOut(whoCheckedOut: String) : boolean
+ advanceDay() : boolean
+ toString() : String

Explanation / Answer

Here is what I started:

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