Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is java problem. I have writen the codes i am not sure what i do wrong, please fix it or add to make it

This is java problem. I have writen the codes i am not sure what i do wrong, please fix it or add to make it works. I am not sure what did i do wrong and why it wont compile this is the direction:

-The Book class models information common to all books.

-The LibraryBook class is a Book, but library books also have a call number, and the call number allows books to be ordered on the shelves. (The ordering is given by a compareTo specified in the Comparable interface. In addition, because many library books can circulate (be checked out and returned), each library book has a circulation status (e.g., on shelf, checked out, permanently in reference collection).

-A ReferenceBook is a type of Library Book that is housed in a specified collection (e.g., a reference area in Tioga, or in the Snoqulamie Building), and reference books do not circulate.

-A CirculatingBook is a type of Library Book located on the shelves until it is checked out, and the book is placed back on the shelves when it is returned.

image text in transcribed

code of book

image text in transcribed

image text in transcribed

This class i miss one which is comparable i am not sure what to do. this is the code

image text in transcribed

image text in transcribed

I am not sure how to write field collection but this is my code:

image text in transcribed

image text in transcribed

This is the code: i think my implement is wrong.

image text in transcribed

and lastly this is my code for the driver because the class is wrong i am not sure what to write here.

driver file Library.java. The driver file is incomplete. Library() constructor addBook() method printLibrary() method findBook() method

these is the code just copy paste:

import java.util.ArrayList;

import java.util.Collections;

public class Library {

// Declare a List of LibraryBook

ArrayList bookList;

Library (ArrayList bookList) {

// TO DO: Instantiate bookList

this.bookList = booklist;

}

/** TO DO:

* adds the given book to the library

* @param book

*/

public void addBook (LibraryBook book) {

Book.setTitle(book);

}

/** TO DO:

* prints all books in the library

*/

public void printLibrary () {

System.out.print(Book.tostring());

}

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

}

ALL the code i have made but i make some error that i could not see or i dont know could you guys help me to fix it so i know what i do wrong, These are not homework. But these are preparation for the next class that i have to take. If i dont know what i did wrong I am scared of what will take next class. Thanks

Class Book The Book class models information common to all books. Any book has: Fields: an author .an ISBN or International Standard Book Number that provides a unique number used by publishers and book stores Constructors and methods: a null constructor a constructor using 3 parameters for an author, title, and ISBN number getters and setters 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 bedone via getters and setters-encapsulation! Class Book The Book class models information common to all books. Any book has: Fields: an author .an ISBN or International Standard Book Number that provides a unique number used by publishers and book stores Constructors and methods: a null constructor a constructor using 3 parameters for an author, title, and ISBN number getters and setters 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 bedone via getters and setters-encapsulation

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

How and why do the genders differ in mental ability scores?

Answered: 1 week ago

Question

Is SHRD compatible with individual career aspirations

Answered: 1 week ago