// lbook.h // ---------------------------------------------------------------------- // Do not modify this file. // declares class LibraryBook // // CSE 143 // Homework 2, 3 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 25 Jun 2000; Ken Yasuhara #ifndef _LBOOK_H_ #define _LBOOK_H_ #include "date.h" #include "lpatron.h" ////////////////////////////////////////////////////////////////////// // constants const int MAX_TITLE_LENGTH = 120; const int MAX_AUTHOR_LENGTH = 60; ////////////////////////////////////////////////////////////////////// // class LibraryBook class LibraryBook { public: // // constructors // // all books are initially assumed to be checked in // constructs book w/ zero ID, null title, author LibraryBook(); // must provide positive ID nubmer, nonempty strings LibraryBook(int newID, char newTitle[], char newAuthor[]); // // accessors // // given a char array, copies this book's title into the array; // assumes that the size of the argument array is sufficient to store // a copy of the title string void getTitle(char spaceForTitleCopy[]); // same as getTitle but for this book's author void getAuthor(char spaceForAuthorCopy[]); // returns the book's ID number; book IDs are always > 0 int getID(); // // borrowing, returning books // // returns true if book is checked out by a patron bool isCheckedOut(); // returns the user ID number of the patron who has this book // checked out; isCheckedOut() must be true int getBorrowerID(); // returns due date of this book; isCheckedOut() must be true Date getDueDate(); // returns true if given date is after this book's due date; // isCheckedOut() must be true bool isOverdue(Date today); // returns number of days by which this book is overdue; isOverdue() // must be true int daysOverdue(Date today); // updates both this book and the given patron to reflect that the // patron checked out (borrowed) the book for the given number of // days (loanDuration) on the given date (today); isCheckedOut() // must be false void checkOut(Date today, LibraryPatron &borrower, int loanDuration); // updates both this book and the given patron to reflect that the // patron checked in (returned) the book; isCheckedOut() must be // true void checkIn(LibraryPatron &returner); // outputs book's ID number, title, author, and check-out status via // cout void printRecord(); private: // // member data // char title[MAX_TITLE_LENGTH]; char author[MAX_AUTHOR_LENGTH]; // set to 0 if this book is not checked out; set to borrower's user // ID (always > 0) when checked out int borrowerID; // only valid when checked out Date dueDate; // book's ID number; > 0; should not change after construction int ID; }; #endif // _LBOOK_H_