Index of /csed/ap/exams/2004/code/AB1
Name Last modified Size Description
Parent Directory -
Book.java 07-May-2004 12:12 318
Library.java 07-May-2004 12:12 1.1K
LibraryBook.java 07-May-2004 12:12 543
LibraryItem.java 07-May-2004 12:12 412
README 07-May-2004 12:12 1.6K
The solution/interface for LibraryItem is straightforward
except for the decision to return a boolean for the method
checkOut. This isn't specified in the problem statement,
but in writing code that manipulates LibraryItems it will
be easier to write the code if the checkOut method returns
whether the item was successfully checked-out.
I doubt that points will be deducted for using either boolean
or void for the return type of checkOut, but that's just
my prediction, not knowledge of how the problem will be graded.
Note that the problem says "cannot change ID of library item", so
there should be no setID() method in LibraryItem. In general,
don't write methods not asked for.
This class must extend Book and implement LibraryItem. It shouldn't
duplicate state from the Book class (so no author/title, those
are accessible via super.getXX methods), but a LibraryBook needs
an ID and a holder, so those instance variables are required. I used
the theXXX naming convention since that's what is used in this problem,
and software engineers/programmers/designers should try to mirror the
style of the code they're adding-to/modifying.
The methods from the LibraryItem interface are straightfoward
given the state of a LibraryBook.
The problem statement pretty much requires a map of IDs->LibraryItems
to facilitate efficient implementation of the checkOut and getHolder
Whether a TreeMap or HashMap is used shouldn't matter, both offer
sublinear expected performance and that's what I interpret
"performed efficiently" to mean in this problem.