Hi All..
I'm trying to write a program in java that would look something like
the following:
======================
Welcome to your Library
======================
Creating catalogue.... Done
Populating catalogue.... Done
The current books in the catalogue are:
Title: The Truth
Author: Terry Pratchett
Year: 2000
Title: The Hitchhikers Guide to the Galaxy
Author: Douglas Adams
Year: 1995
Title: The Root of all Evil
Author: JD Frazer
Year: 2001
to build it I was thinking of having three classes: Library (used to
drive the program), Catalogue and Book..
I don't know if I'm in the right track, but in the Library class, have
method filldata() which would create an instance of catalogue and
populate the catalogue and print it..
In the catalogue class have methods such as addbook(), getbook(), and
printCatalogue(), which will talk to and get information from Books
class..
Has anyone ever written something similar? If not, I'm sure it's not
very hard to do, if someone could perhaps write the backbone of the
program and I'll finish up the specifics.. It'd be very helpful..
Thanks..
bec.
Solar - 07 Apr 2006 11:26 GMT
I thought the purpose of homework assignments was for you to do them
yourself. If its not very hard to do, I'm sure you'll have no problem
doing it :-)
-- Matt
Roedy Green - 07 Apr 2006 19:21 GMT
>In the catalogue class have methods such as addbook(), getbook(), and
>printCatalogue(), which will talk to and get information from Books
>class..
Just think in English.
I have a Book class. What facts do I want to keep about each book.
Make a field for each one, a getter and setter.
I have a Calalogue. It is a Collection of books. You want to look up
by what? You might use a HashMap to look up by ISBSN, Treeset by
author last name. you might have keywords you look up by HashMap or
TreesSet
If you track circulation you have a Borrower record. Again set up the
relevant fields.
The Borrower has a minicollecition of books he has out.
You might have a BorrowedBook class that extends book that tracks who
has it out and when it is due back.
Now you think about what fields change when a borrower borrows a book,
brings one back.
You can invent the lookup methods in the catalo, given x you get back
a list of looks.
Now you have to think about persistence. You can simply load
everything into ram and save it all with serialised objects. Or you
can use a database (how you would do it in real life) or a POD.
It depends on just how real this exercise is expected to be.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.