GIVEN //BookMain.java //This is the client code of Book class public class BookMain{ public static void main(String[] arguments){ // Small test of the Book class Book example = new Book("Angels and Demons"); System.out.println("Title (should be Angels and Demons): " + example.getTitle()); System.out.println("Rented? (should be false): " + example.isBorrowed()); example.rented(); //marks the book as rented System.out.println("Rented? (should be true): " + example.isBorrowed()); example.returned();//marks the book as returned System.out.println("Rented? (should be false): " + example.isBorrowed()); } GIVEN //Book.java //complete the missing implementation to this class public class Book{ private String title; private boolean borrowed; // Creates a new Book (constructor) public Book(String bookTitle){ // Implement this method } // Marks the book as rented public void rented() { // Implement this method } // Marks the book as not rented public void returned() { // Implement this method } // Returns true if the book is rented, false otherwise public boolean isBorrowed() { // Implement this method } // Returns the title of the book public String getTitle() { // Implement this method } } GIVEN //LibraryMain.java // This is the client code of Library class //complete the missing static method(s) in this code public class LibraryMain { public static void main(String[] args){ // Create two libraries Library firstLibrary = new Library("101 Big Street"); Library secondLibrary = new Library("228 Wonderland"); // Add four books to the first library firstLibrary.addBook(new Book("Angels and Demons")); firstLibrary.addBook(new Book("The Maze Runner")); firstLibrary.addBook(new Book("I See You")); firstLibrary.addBook(new Book("Fantastic Beasts and Where to Find Them")); // Print opening hours and the addresses System.out.println("Library hours:"); printOpeningHours(); System.out.println(); System.out.println("Library addresses:"); firstLibrary.printAddress(); secondLibrary.printAddress(); System.out.println(); // Try to borrow The Lords of the Rings from both libraries System.out.println("Borrowing The Maze Runner:"); firstLibrary.borrowBook("The Maze Runner"); firstLibrary.borrowBook("The Maze Runner"); secondLibrary.borrowBook("The Maze Runner"); System.out.println(); // Print the titles of all available books from both libraries System.out.println("Books available in the first library:"); firstLibrary.printAvailableBooks(); System.out.println(); System.out.println("Books available in the second library:"); secondLibrary.printAvailableBooks(); System.out.println(); // Return The Maze Runner to the first library System.out.println("Returning The Maze Runner:"); firstLibrary.returnBook("The Maze Runner"); System.out.println(); // Print the titles of available from the first library System.out.println("Books available in the first library:"); firstLibrary.printAvailableBooks(); }//main }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

GIVEN
//BookMain.java
//This is the client code of Book class

public class BookMain{

public static void main(String[] arguments){
// Small test of the Book class
Book example = new Book("Angels and Demons");
System.out.println("Title (should be Angels and Demons): " + example.getTitle());
System.out.println("Rented? (should be false): " + example.isBorrowed());
example.rented(); //marks the book as rented
System.out.println("Rented? (should be true): " + example.isBorrowed());
example.returned();//marks the book as returned
System.out.println("Rented? (should be false): " + example.isBorrowed());
}

GIVEN
//Book.java
//complete the missing implementation to this class

public class Book{
private String title;
private boolean borrowed;

// Creates a new Book (constructor)
public Book(String bookTitle){
// Implement this method
}

// Marks the book as rented
public void rented() {
// Implement this method
}

// Marks the book as not rented
public void returned() {
// Implement this method
}

// Returns true if the book is rented, false otherwise
public boolean isBorrowed() {
// Implement this method
}

// Returns the title of the book
public String getTitle() {
// Implement this method
}

}

GIVEN
//LibraryMain.java
// This is the client code of Library class
//complete the missing static method(s) in this code

public class LibraryMain {

public static void main(String[] args){
// Create two libraries
Library firstLibrary = new Library("101 Big Street");
Library secondLibrary = new Library("228 Wonderland");

// Add four books to the first library
firstLibrary.addBook(new Book("Angels and Demons"));
firstLibrary.addBook(new Book("The Maze Runner"));
firstLibrary.addBook(new Book("I See You"));
firstLibrary.addBook(new Book("Fantastic Beasts and Where to Find Them"));

// Print opening hours and the addresses
System.out.println("Library hours:");
printOpeningHours();
System.out.println();
System.out.println("Library addresses:");
firstLibrary.printAddress();
secondLibrary.printAddress();
System.out.println();

// Try to borrow The Lords of the Rings from both libraries
System.out.println("Borrowing The Maze Runner:");
firstLibrary.borrowBook("The Maze Runner");
firstLibrary.borrowBook("The Maze Runner");
secondLibrary.borrowBook("The Maze Runner");
System.out.println();

// Print the titles of all available books from both libraries
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
System.out.println();
System.out.println("Books available in the second library:");
secondLibrary.printAvailableBooks();
System.out.println();

// Return The Maze Runner to the first library
System.out.println("Returning The Maze Runner:");
firstLibrary.returnBook("The Maze Runner");
System.out.println();

// Print the titles of available from the first library
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
}//main

}

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 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:
101 Big Street.
228 Wonderland.
Borrowing The Maze Runner:
You successfully borrowed The Maze Runner
Sorry, this book is already borrowed.
Sorry, this book is not in our catalog.
Books
available
in
the
first
library:
Angels and Demons
I Šee You
Fantastic Beasts and Where to Find Them
Books available in the second library:
No book in catalog
Returning The Maze Runner:
You successfully returned The Maze Runner
Books available in the first library:
Angels and Demons
The Maze Runner
I See You
Fantastic Beasts and Where to Find Them
Transcribed Image Text: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 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: 101 Big Street. 228 Wonderland. Borrowing The Maze Runner: You successfully borrowed The Maze Runner Sorry, this book is already borrowed. Sorry, this book is not in our catalog. Books available in the first library: Angels and Demons I Šee You Fantastic Beasts and Where to Find Them Books available in the second library: No book in catalog Returning The Maze Runner: You successfully returned The Maze Runner Books available in the first library: Angels and Demons The Maze Runner I See You Fantastic Beasts and Where to Find Them
The libraries of Smallville need a new electronic rental system, and it
is up to you to build it. Smallville has two libraries. Each library offers
many books to rent. Customers can print the list of available books,
borrow, and return books. This system has two classes, 2=x and
zasrary, that provide the functionality for the book database. You must
implement the missing methods to make these classes work.
Step One: Implement Book
First you need a class to model books. Start by completing a class called
2s* (Book.java). This class defines methods to get the title of a book, find
out if it is available, borrow the book, and retum the book. However, the
skeleton provided is missing the implementations of the methods. Fill in
the body of the methods with the appropriate code. The -asn method in
BookMain.java tests the methods. When you run the BookMain.java
program, the output should be:
tie (ahouid ba Angala and Damona): Angeia and Danona
Rantad? (ahould ba falaa): iaa
Rantad? (ahould be :rua) : rus
Rantad? (ahould ba falaA): :iaa
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 you 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., arrays of 2==x objects).
Create a class :rary code in a file named Library.java You will need to
define and implement the missing methods in Library.java.
LibraryMain.java provides a masn method that creates two libraries, then
performs some operations on the books. Read the masn method and look
at the compile errors to figure out what methods are missing.
Hint: Use ArrayList to create books collection.
Notes
• Some methods will need to be siatic methods, and some need to be
instance methods.
careful
Be
when
comparing Strings objects.
Use
1sngi.quai1(22ing2) for comparing the contents of atring: and
Transcribed Image Text:The libraries of Smallville need a new electronic rental system, and it is up to you to build it. Smallville has two libraries. Each library offers many books to rent. Customers can print the list of available books, borrow, and return books. This system has two classes, 2=x and zasrary, that provide the functionality for the book database. You must implement the missing methods to make these classes work. Step One: Implement Book First you need a class to model books. Start by completing a class called 2s* (Book.java). This class defines methods to get the title of a book, find out if it is available, borrow the book, and retum the book. However, the skeleton provided is missing the implementations of the methods. Fill in the body of the methods with the appropriate code. The -asn method in BookMain.java tests the methods. When you run the BookMain.java program, the output should be: tie (ahouid ba Angala and Damona): Angeia and Danona Rantad? (ahould ba falaa): iaa Rantad? (ahould be :rua) : rus Rantad? (ahould ba falaA): :iaa 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 you 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., arrays of 2==x objects). Create a class :rary code in a file named Library.java You will need to define and implement the missing methods in Library.java. LibraryMain.java provides a masn method that creates two libraries, then performs some operations on the books. Read the masn method and look at the compile errors to figure out what methods are missing. Hint: Use ArrayList to create books collection. Notes • Some methods will need to be siatic methods, and some need to be instance methods. careful Be when comparing Strings objects. Use 1sngi.quai1(22ing2) for comparing the contents of atring: and
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY