Public Library Model


Design

Main class PublicLibrary keeps list of all Books and Patrons and implements general operation (checkout, checkin, place on hold, checking of expired OnHold records). Also, PublicLibrary includes OnHoldManager, which implements all manipulations with list of reservations. Class Checkout keeps all information about checkout and creates HistoryRec object after checkin. Class Patrons also includes list of all fines for overdue and lost books (uses class Fine). Class Date is used for general operation with date.

Realization

Because all books have to have unique identifiers and individual copies are held for specific person, I used map for keeping all books and created unique identifiers for second and following copies by adding number of copy to title (e.g. "some book", "some book (copy 1)", "some book (copy 2)"). Object Checkout before deleting itself, creates new object HistoryRec (for history keeping and links that are used for fines' description). Class PublicLibrary includes method goToNextDay which calls method checkExpiredOnHold automatically. For all operations with books, in general, books' titles should be used (from map or getTitle()), because they include number of copy (that is wrong in case of 'books[]' from 'testdata.h')