// lpatrlst.h // ---------------------------------------------------------------------- // declaration and consts for class LibraryPatronList; a sorted vector of // LibraryPatron objects // modified copy of ListA.h/cpp, Carrano et al. // // CSE 143 // Homework 3 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 05 Jul 2000; Ken Yasuhara #ifndef _LPATRLST_H_ #define _LPATRLST_H_ #include "lpatron.h" const int MAX_PATRON_COUNT = 100; const int PATRON_ENTRIES_PER_SCREEN = 5; class LibraryPatronList { public: // constructs an empty list LibraryPatronList(); // constructs a list initialized from data file w/ given name; see // private method readFile LibraryPatronList(char dataFileName[]); // destructor is supplied by compiler // // list operations // // *** Using class LibraryBookList as a model, declare list // operation methods here (and define them in lpatrlst.cpp). Keep // in mind that though this list class will be similar to // LibraryBookList, because this list keeps items in sorted order, // there will be some important differences in both public interface // and implementation (e.g. consider the insert operation). // Determines whether a list is empty. // Precondition: None. // Postcondition: Returns true if the list is empty, // otherwise returns false. // *** declaration here // Determines the length of a list. // Precondition: None. // Postcondition: Returns the number of items // that are currently in the list. // *** declaration here // Inserts an item into a list, choosing its position such that // sorted order is maintained. // Precondition: given item is the item to be inserted. // Postcondition: If insertion was successful, the item is in the // list, other items are renumbered accordingly, and the list is in // sorted order // *** declaration here // Deletes an item from a list. // Precondition: given position indicates where the deletion // should occur, i.e. which item should be deleted // Postcondition: If 0 <= position < getLength(), // the item at the given position in the list is // deleted and other items are renumbered accordingly // *** declaration here // replaces item at given position w/ given (updated) item, if // position is in valid range (from 0 to getLength() - 1) // *** declaration here // Retrieves a list item by position number. // Precondition: given position is the number of the item to // be retrieved. // Postcondition: If 0 <= given position < getLength(), the item at // the given position is copied into a reference parameter // *** declaration here // attempts to find item w/ given ID and assigns a copy to reference // parameter if an item w/ given ID exists in the list // *** declaration here // attempts to find item w/ given ID and returns its position, if an // item w/ given ID exists in the list; it not, -1 (an invalid // position) is returned // *** declaration here // prints list items in increasing order from position 0 // *** declaration here private: // *** member variables here // used by data file constructor; opens given file and reads patron // data into this list void readFile(char fileName[]); // *** Consider adding a private helper function for the insertion // method, e.g. findSortedPosition, which determines which position // some given element should be inserted at so that sorted order is // maintained. }; // end class // End of header file. #endif // _VECTOR_H_