Question: JAVA PROGRAMMING Hello, I'm trying to modify a library solution and I'm trying to create a new datatype to take the place of the various

JAVA PROGRAMMING

Hello, I'm trying to modify a library solution and I'm trying to create a new datatype to take the place of the various arrays used in the solution to keep track of different aspects of the books being rented. It's similar to the playing card examples in Think Java. anyways...

This is how far I've got...

public class Book { private String getName; private String getAuthor; public String getAuthor(){ return getAuthor; } public String getTitle() { return getName; } Book(String author,String title){ super(); this.getAuthor = author; this.getName = title; } public String toString(){ String title = null; String author = null; return"Book[author="+ null +",title="+ null +"]"; } } 

I created a class that has a constructor with two String-type parameters holding the name and author of the book.

Now I'm trying to update the Book class to keep track of the rental information. So what I need is to creat an additional constructor which has three string parameter: the name and author of the book and the name of a renter. if the original constructor is called, the resulting object should initially be considered not rented.

Next, add the following methods to the class:

  1. boolean isRented() - has no parameters and returns a boolean. Returns true if the book is currently rented and false otherwise.
  2. rent(String renterName) - has one String type parameter and no return type. Rents the book out to the specified renter and sets the due date to be a week from the current date.
  3. returnToLibrary() - has no parameters and no return type. Removes rental information from the book. After this call, isRented() will return false until the next time the book is rented.
  4. String getRenter() - has no parameters and returns a String object representing the name of the renter of this book. If the book is not rented, this method should return null.
  5. LocalDate getDueDate() - has no parameters and returns a LocalDate (LocalData) object representing the date on which the book is due. If the book is not rented, this method should return null.

Please comment if there is anything else needed. Thanks alot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!