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:
- boolean isRented() - has no parameters and returns a boolean. Returns true if the book is currently rented and false otherwise.
- 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.
- 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.
- 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.
- 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.
Thanks a lot
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started