Write My Paper Button

WhatsApp Widget

Assignment The libraries of SmallTownX need a new electronic rental system, and it is up to you to build it. SmallTownX has two libraries. Each library offers many books to rent. Customers can print the list of available books,

Assignment

The libraries of SmallTownX need a new electronic rental system, and it is up to you to build it. SmallTownX has two libraries. Each library offers many books to rent. Customers can print the list of available books, and borrow, and return books.

Problem

We provide two classes, Book and Library, that provide the functionality for the book database. You must implement the missing methods to make these classes work.

Step One: Implement Book First we need a class to model books. Start by creating a class called Book. Copy and paste the skeleton below. This class defines methods to get the title of a book, find out if it is available, borrow the book, and return the book. However, the skeleton that we provide is missing the implementations of the methods. Fill in the body of the methods with the appropriate code. The main method tests the methods. When you run the program, the output should be: Title (should be The Da Vinci Code): The Da Vinci Code Rented? (should be false): false Rented? (should be true): true Rented? (should be false): false

Notes

  • Some methods will need to be static methods, and some need to be instance methods.
  • Be careful when comparing Strings objects. Use string1.equals(string2) for comparing the contents of string1 and string2.
  • You should get a small part working at a time. Start by commenting the entire main method, then uncomment it line by line. Run the program, get the first lines working, then uncomment the next line, get that working, etc. You can comment a block of code in Eclipse by selecting the code, then choosing Source → Toggle Comment. Do the same again to uncomment it.
  • You must not modify the main method.

The output when you run this program should be similar to the following:

Library hours:

Libraries are open daily from 9am to 5pm.

Library addresses:

10 Main St. 228 Liberty St.

Borrowing The Lord of the Rings:

You successfully borrowed The Lord of the Rings Sorry, this book is already borrowed. Sorry, this book is not in our catalog.

Books available in the first library:

The Da Vinci Code

Le Petit Prince

A Tale of Two Cities

Books available in the second library:

No book in catalog

Returning The Lord of the Rings:

You successfully returned The Lord of the Rings

Books available in the first library:

The Da Vinci Code

Le Petit Prince

A Tale of Two Cities

The Lord of the Rings

If any of you have experience with Java or similar assignments, I would greatly appreciate your insights or guidance on how to approach this problem. I’m not looking for a complete solution; I’m more interested in the learning experience.

Scroll to Top