//***************************************************************************** // Header file party.h for the party class. // Programming Project 4 // CS 241 Data Structures // Fall 2003 //***************************************************************************** #ifndef PARTY_H #define PARTY_H using namespace std; #include #include #include #include "IOExceptions.h" // Global constants defined for the field widths in the output format. const int NAME_WIDTH = 14; const int TELEPHONE_WIDTH = 10; const int NUMBER_WIDTH = 4; const int ARRIVAL_WIDTH = 7; const int DEPARTURE_WIDTH = 7; const int GAMES_WIDTH = 9; const int SHOES_WIDTH = 9; void printHeader(ostream& out) throw(outputException); // Pints the header to the out stream // Precondition: out is a valid ostream ready for output // Postcondition: A single line is output to the out stream // containing header information. Each field is output using // the width defined above. // Exception: If out ever enters the fail state, an outputException // excpetion is thrown. class party { public: // constructors party(); // default constructor. Leave all data members uninitialized but party(string name, string telephone, int number, string arrival, string departure, int games, int shoes); // second constructor. Initializes all data members to corresponding // parameter values. // querying functions void printOut(ostream& out) const throw(outputException); // Precondition: out is a valid ostream ready for output // Postcondition: The output occurs on a single line in the // following order: partyName, telephoneNumber, numberInParty, // arrivaltime, departureTime, gamesBowled, numShoesRented. // Each field is output using the proper width defined above. // All text and time fields are left justified. All numeric // fields are right justified // Exception: If out ever enters the fail state, an outputException // exception is thrown. bool matches(const party& A) const; // Determines if A exactly matches this party // Precondition: both A and this instance have been initialized. // Postcondition: returns true if the two instances are identical // in all data fields. Returns false otherwise. // functions that modify the class void readIn(istream& in) throw(inputException); // Reads a single party record from input stream in. // Precondition: in is a valid istream ready for reading // Postcondition: If EOF is detected on the first read, the stream // was at EOF upon entry, In this case, the function returns without // changing any data members. Otherwise, the data members are read // in the following order: partyName, telephoneNumber, // numberInParty, arrivaltime, departureTime, gamesBowled, // numShoesRented. Each data item is whitespace delineated (no // spaces allowed in the middle of a field). // Exception: If in every enters the fail state other than an // initial EOF, an inputException exception is thrown. void transfer(const party& A); // Copies party A into the party object. // Precondition: both A and this instance have been initialized. // Postcondition: The data members of this instance contain an // exact copy of the data members of A. private: string partyName; string telephoneNumber; int numberInParty; string arrivalTime; string departureTime; int gamesBowled; int numShoesRented; }; #endif