Question: Fixing the main function i have my code done but i am not sure how to fix the main code of it (JAVA) these are

Fixing the main function i have my code done but i am not sure how to fix the main code of it (JAVA) these are the codes

Fixing the main function i have my code done but i am

not sure how to fix the main code of it (JAVA) theseare the codes these are the main code that need to befix' import java.util.ArrayList; import java.util.Collections; public class Library { ArrayList bookList; Library

these are the main code that need to be fix'

import java.util.ArrayList;

import java.util.Collections;

public class Library {

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();

}

}

public class Book protected String author; protected String title: protected int ISBN: public String getAuthor) return author; public void setAuthor (String aAuthor) i author-aAuthor; public String getTitle) return title public void setTitle (String aTitle) t title-aTitle: public int getIsBN ) return ISBN; public void setISBN (int aISBN) ISBNaISBN; public Book (String aAuthor, String aTitle, int aISBN) I super ): author-aAuthor; titleaTitle; ISBNaISBN public Book //end of class Book

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!