Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need this ASAP using java Driver file port java.util.ArrayList; import java.util.Collections; public class Library { // Declare a List of LibraryBook ArrayList bookList; Library ()

Need this ASAP using java
image text in transcribed
image text in transcribed
image text in transcribed
Driver file
port java.util.ArrayList;
import java.util.Collections;
public class Library {
// Declare a List of LibraryBook
ArrayList bookList;
Library () {
// TO DO: Instantiate bookList
}
/** TO DO:
* adds the given book to the library
* @param book
*/
public void addBook (LibraryBook book) {
}
/** TO DO:
* prints all books in the library
*/
public void printLibrary () {
}
/** TO DO:
* locates a book in the library
* @param book book being search in the library
* @return book object if book is found
* null otherwise
*/
public LibraryBook findBook (LibraryBook book) {
int index = Collections.binarySearch(bookList, book);
/* @return book object if book is found
* null otherwise
*/
}
/**
* sort books in the library by call number
*/
public void sortLibrary () {
Collections.sort(bookList);
}
/**
* performs processing for checking a book out of the library
* @param patron person checking out book
* @param dueDate date book is due to be returned
* @param callNum call number of book
*/
public void checkout (String patron, String dueDate, String callNum) {
LibraryBook searchItem = new CirculatingBook ("", "", "", callNum);
LibraryBook book = findBook(searchItem);
if (book == null)
System.out.println ("Book " + callNum + " not found -- checkout impossible ");
else
book.checkout (patron, dueDate);
}
/**
* processes checked-out book that is being returned
* @param callNum call number of book being returned
*/
public void returned (String callNum) {
LibraryBook searchItem = new CirculatingBook ("", "", "", callNum);
LibraryBook book = findBook(searchItem);
if (book == null)
System.out.println ("Book " + callNum + " not found -- return impossible ");
else
book.returned ();
}
/**
* main testing program
* @param args not used
*/
public static void main (String args[]) {
Library lib = new Library ();
// set up library
lib.addBook(new ReferenceBook ("Henry M. Walker",
"Problems for Computer Solution using BASIC",
"0-87626-717-7", "QA76.73.B3W335", "Iowa Room"));
lib.addBook(new ReferenceBook ("Samuel A. Rebelsky",
"Experiments in Java",
"0201612674", "64.2 R25ex", "Iowa Room"));
lib.addBook(new CirculatingBook ("John David Stone",
"Algorithms for functional programming",
"in process", "forthcoming"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"Computer Science 2: Principles of Software Engineering, Data Types, and Algorithms",
"0-673-39829-3", "QA76.758.W35"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"Problems for Computer Solution using FORTRAN",
"0-87626-654-5", "QA43.W34"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"Introduction to Computing and Computer Science with Pascal",
"0-316-91841-5", "QA76.6.W3275"));
lib.addBook(new CirculatingBook ("Samuel A. Rebelsky and Philip Barker",
"ED-MEDIA 2002 : World Conference on Educational Multimedia, Hypermedia & Telecommunications",
"14. 1-880094-45-2", "64.2 25e"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"Pascal: Problem Solving and Structured Program Design",
"0-316-91848-2", "QA76.73.P2W35"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"The Limits of Computing",
"0-7637-2552-8", "QA76.W185"));
lib.addBook(new CirculatingBook ("Henry M. Walker",
"The Tao of Computing",
"0-86720-206-8", "QA76.W1855"));
// sort books by call number
lib.sortLibrary();
// print library
lib.printLibrary();
// some users check out and return books
lib.checkout("Donald Duck", "March 1, 2012", "QA43.W34");
lib.checkout("Donald Duck", "March 12, 2012", "QA76.6.W3275");
lib.checkout("Donald Duck", "March 6, 2012", "64.2 R25ex");
lib.checkout("Minnie Mouse", "April 1, 2012", "64.2 25e");
lib.checkout("Goofy", "February 28, 2012", "12345"); // should fail
lib.returned("QA76.6.W3275");
lib.returned("64.2 R25ex");
lib.checkout("Goofy", "March 28, 2012", "QA76.6.W3275");
// print final status of library
lib.printLibrary();
}
}
class and its subclasses A more detailed description of these classes follows Class Book The Book class models information common to all books. Any book has: Fields: o an author o a title o an ISBN or International Standard Book Number that provides a unique number used by publishers and book o a null constructor o a constructor using 3 parameters for an author, title, and ISBN number o getters and setters o toString should provide a string of the field data in a format suitable for printing Within a Book class and its subclasses, these fields might be used directly, but processing by other classes and objects should be done via getters and setters- encapsulation! Class LibraryBook The LibraryBook class models information common for library books. In addition to author, title, and ISBN, library books have call numbers, and library books are stored on the shelves in order by call number. Further, many library books may be able to circulate. In addition to fields and methods of books, any library book has: Fields: o call number Constructors and methods: o a constructor using 4 parameters for an author, title, ISBN number, and call number o getters and setters o checkout handles processing for a patron to check out a o returned handles o circulationStatus indicates whether the book is on book. A due date also is recorded returned after having been checked out. the shelves, checked, or non-circulating in the reference processing for when a book is collection mpareTo allows comparison/ordering of library books, following the format Java's Comparable interface. o co

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

More Books

Students also viewed these Databases questions

Question

What is the formula used for computing BIC?

Answered: 1 week ago