hi everybody, I'm having a problem on what to do next in my project. below is what i need to do.
if any body let me know if i'm doing it right and if i need more classes. help on boolean, clone and finalize method. Thank you...

A library needs to keep track of its books. Write a class called Book to hold information on a book. Various attributes of a book are its title, author(allow up to four authors), ISBN number, publisher, copyright date, price, etc. Include all appropriate accessor and mutator methods. Include a boolean to determine if the book is checked out or available in the library. Override the Object methods appropriately (equals, hashCode, toString, etc.). Implement cloning of a book. Include a static member called nBooks which will be used to keep up with the total number of instances of Book you have in the library (hint: to do this you will need to add code to all constructors and also include a finalize method). Write a test program that will create at least 10 books, cloning at least one. Display the number of books at the beginning of the program (should be zero). After each book is created display the total number of instances of Book existing at that time. Test checking out books and checking in books. Display a list of all the books showing which ones are checked out. Use the equals method to discover and remove the cloned book(s). Add up the total cost of all of the books in the library. At the end display the number of instances of book before exiting the test program.

public abstract class Book implements Cloneable
	public static int nBooks=0;

	public static String ISBN;
	private String title;
	//private char type; //Single character since it will be read as a single letter.
	//private String status;
	private String author;
	private String publisher;
	//private String dateborrowed;
	private String copyRightDate;
	private double price;

	//public Book (){}
public Book ( String a, String b, String c, String d, String e, double f )
	title= b;

	nBooks ++;
}//end book constructor

	//set method
public static void setISBN(String a) { ISBN = a; }

	//Accessors (getters)

public static String getISBN() { return ISBN; }

public void setTitle(String b) { title = b; }

public String getTitle() { return title; }

public void setAuthor(String c) { author = c; }

public String getAuthor() { return author; }

public void setPublisher(String d) { publisher = d; }

public String getPublisher() { return publisher; }

public void setCopyRightDate( String e ) { copyRightDate = e; }

public String getCopyRightDate() { return copyRightDate; }

public void setPrice( double f ) { price = f; }

public double getPrice() { return price; }

//public String getDateborrowed(){ return dateborrowed; }
public static void setNBooks() { nBooks = 0; }

public static int getNBooks(){ return nBooks; }

// return String representation of Employee object
   public String toString()
      return String.format( "%s %s\nISBN: %s\nTitle: %s",
         getISBN(), getTitle(), getAuthor(), getPublisher(), getCopyRightDate(), getPrice() );
   } // end method toString

   // abstract method overridden by subclasses
   public abstract double earnings(); // no implementation here

   public Object clone()
	   Book e = null;
		   e = (Book) super.clone();
	   catch (CloneNotSupportedException cnse)
		   throw new InternalError(cnse.toString());
	   e.ISBN = (Book) ISBN.clone();

	   return e;


public class BookTest
	public static void main(String[] args)
			Book firstBook = new Book("Horton Hears A Who!","Dr. Seuss","Random House");
			Book secondBook = new Book("The Cat In The Hat","Dr. Seuss","Random House");
			Book anotherBook = new Book("The Maltese Falcon","Dashiell Hammett","Orion");

		}//end main

}//end BookTest
7 Years
Discussion Span
Last Post by sneaker


Begin whit this site:
and read about:
Class Object
Interface Cloneable
Class Boolean
You will find them in java.lang.

Then Google for examples of these and begin to try from there.
You can also Google to see if there are information on similar projects.

Write your classes on paper whit name of the class and name of instance variables and methods that belongs to the class. Try to think about how the classes you have written down will be connected to each other. That gives you an overview to begin whit.

You have to store the book-objects in some way, make a decision of how.

Some kind of GUI is perhaps needed? Do not mix the GUI whit the logic, try to separate it.

Do not forget to test your code piece for piece. This makes it easier for you to detect when and where there is something wrong.

Good luck =)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.