Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need the full code PROBLEM The libraries of Umm Alqura University need a new book rental system, and it is up to you to

i need the full code

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

PROBLEM The libraries of Umm Alqura University need a new book rental system, and it is up to you to build it. Umm Alqura University has two libraries. Each library offers many books to rent. Students and instructors can print the list of available books, borrow, and return books. We provide two classes, Book and Library, that provide the functionality for the book rental system. You must implement the missing methods to make these classes work. STEP ONE: IMPLEMENT BOOK First, start by creating a class called Book. Copy and paste the code below. This class defines methods to get the title of a book, find out if it is available, rent the book, and return the book. However, the code 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 Learn Java in 5 Minutes): Learn Java in 5 Minutes Rented? (should be false): false Rented? (should be true): true Rented? (should be false): false Hint: Look at the main method to see how the methods are used, then fill in the code for each method. STEP TWO: IMPLEMENT LIBRARY Next we need to build the class that will represent each library, and manage a collection of books. All libraries have the same hours: 9 AM to 5 PM daily. However, they have different addresses and book collections (i.e., vectors of Book objects). Create a class called Library. Copy and paste the code below. We provide a main method that creates two libraries, then performs some operations on the books. However, all the methods and member variables are missing. You will need to define and implement the missing methods. Read the main method and look at the compile errors to figure out what methods are missing. 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 ma method, then uncomment it line by line. Run the program, get the first lines working, then uncomme the next line, get that working, etc. 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: UQU Library 1 UQU Library 2 Books available in the first library: Algorithms to Live By Introduction to Database Systems Calculus Java Programming Borrowing Java Programming You successfully borrowed Java Programming Sorry, this book is already borrowed. Sorry, this book is not in our catalog. Books available in the first library: Algorithms to Live By Introduction to Database Systems Calculus Books available in the second library: No book in catalog Returning Java Programming You successfully returned Java Programming Books available in the first library: Algorithms to Live By Introduction to Database Systems Calculus Java Programming SUBMISSION INSTRUCTIONS Submit both files (Book.java and Library.java) to Blackboard assignment as groups. Good luck! BOOK.JAVA private class Book \{ String title; boolean borrowed; // Creates a new Book public Book(String bookTitle) \{ // Implement this method \} // Marks the book as borrowed public void borrow() \{ // Implement this method \} // Marks the book as not borrowed // Implement this method // Returns true if the book is borrowed, false otherwise public boolean isBorrowed() \{ // Implement this method // Returns the title of the book public String getTitle() \{ // Implement this method public static void main(String[] arguments) \{ // Small test of the Book class Book example = new Book("Learn Java in 5 Minutes"); System.out.println("Title (should be Learn Java in 5 Minutes): " + example.getTitle()); System. out.println("Rented? (should be false): " example.isBorrowed()); example.borrow(); System. out.println("Rented? (should be true): " example.isBorrowed()); example. returnToLibrary(); System.out.println("Rented? (should be false): " + example.isBorrowed()); RY.JAVA System. out. print ln(); // Print the titles of all available books from both libraries System. out.println("Books available in the first library:"); firstlibrary.printAvailableBooks (); System. out. print ln(); System. out.println("Books available in the second library:"); secondLibrary.printAvailableBooks ( ); System. out. print ln(); // Return The Lords of the Rings to the first library System.out. println("Returning Java Programming"); firstLibrary. returnBook( "Java Programming"); System. out. print ln(); // Print the titles of available from the first library System. out. println("Books available in the first library:"); firstlibrary.printAvailableBooks ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

5. Who should facilitate the focus group?

Answered: 1 week ago