// lpatron.h // ---------------------------------------------------------------------- // Do not modify this file. // declares class LibraryPatron // // CSE 143 // Homework 3 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 02 Jul 2000; Ken Yasuhara #ifndef _LPATRON_H_ #define _LPATRON_H_ ////////////////////////////////////////////////////////////////////// // constants const int MAX_NAME_LENGTH = 60; // limit on number of books a patron can have checked out at a time const int MAX_CHECKOUTS = 4; ////////////////////////////////////////////////////////////////////// // class LibraryPatron class LibraryPatron { public: // // constructors // // all patrons initially have no books checked out // constructs patron w/ zero ID, null name LibraryPatron(); // given ID must be > 0, name must be nonnull LibraryPatron(int newID, char newName[]); // // accessors, related methods // // given a char array, copies this patron's name into the array; // assumes that the size of the argument array is sufficient to // store the copy void getName(char spaceForCopy[]); // returns the patron's ID number; valid patron IDs are always > 0 int getID(); // given an int array, copies this patron's list of borrowed book // IDs into the array; see member variable borrowedBookIDs below; // assumes that the size of the argument array is sufficient to // store the copy void getBorrowedBooks(int bookIDs[MAX_CHECKOUTS]); // returns the number of books this patron currently has checked out int getBorrowedCount(); // returns an int < 0 if this patron should come before otherPatron // when sorted in alphabetical order by name; returns 0 if patrons // have same name; returns an int > 0 if this patron should come // after otherPatron... int compare(LibraryPatron otherPatron); // // tracking borrowed books // // updates this patron's records to reflect that he/she has borrowed // or returned the book w/ the given ID void registerCheckOut(int bookID); void registerCheckIn(int bookID); // returns true only if this patron has not reached his/her limit on // the number of books which can be checked out at once bool canCheckOutMore(); // returns true only if this patron bool hasCheckedOut(int bookID); // // I/O // // prints this patron's ID number, name, and the IDs of the books // he/she has checked out void printRecord(); private: // // member data // char name[MAX_NAME_LENGTH]; // positive for any valid patron int ID; // stores IDs of books checked out by this patron; all elements are // 0 if no books checked out; each checked out book has its ID // stored at exactly one index in this array; nonzero elements may // be separated by zero elements int borrowedBookIDs[MAX_CHECKOUTS]; }; #endif // _LPATRON_H_