// this is the interface for studentClass, which stores student data #ifndef STUDENT_CLASS_H #define STUDENT_CLASS_H #include "globals.h" // struct for reading in addresses: struct addressStruct { string lineA, // first line of address lineB, // second line of address city, // city state, // state zip; // zip code }; class studentClass // studentClass stores info on a student and methods to manipulate and report that info { private: bool flagData; // flags whether this particular object is being used string emailData, // email address nameData, // name addressData, // address otherData, // miscellaneous other info phoneData; // phone number addressStruct addressDataB; // used to read in address void assignAddress(); // converts from addressStruct to string // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // addressData stores the address from addressDataB // RETURNS // void // CALLS // none // CALLED BY // studentClass::address void zipCode( istream& ); // reads in zip code from istream to addressStruct // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // zip code is read from inStream and stored in addressDataB // RETURNS // void // CALLS // none // CALLED BY // studentClass::address void state( istream& ); // reads state from stream to addressStruct // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // state is read from inStream and stored in addressDataB // RETURNS // void // CALLS // none // CALLED BY // studentClass::address void city( istream& ); // reads city from stream to addressStruct // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // city is read from inStream and stored in addressDataB // RETURNS // void // CALLS // none // CALLED BY // studentClass::address public: // MUTATORS: virtual void address( istream& ); // reads address from a stream into addressData virtual void flag( const bool FLAG ) { flagData = FLAG; } // assigns flagData which lets whatever is using this object to know if it's in use or been deleted bool readAll( istream& ); // reads student info from a stream into this // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // all fields have been read from inStream and assigned appropriately // RETURNS // bool whether read and assignment were successful // CALLS // phone // email // address // other // name // CALLED BY // operator << virtual bool phone( istream& ); // reads phone number from stream // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // phone number has been read from inStream and assigned to phoneData // RETURNS // bool whether read and assignment were successful // CALLS // none // CALLED BY // readAll virtual bool email( istream& ); // reads email address from stream // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // email address has been read from inStream and assigned to addressData // RETURNS // bool whether read and assignment were successful // CALLS // none // CALLED BY // readAll virtual bool other( istream& ); // reads miscellaneous info field from stream // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // miscellaneous info has been read from inStream and assigned to otherData // RETURNS // bool whether read and assignment were successful // CALLS // none // CALLED BY // readAll virtual bool name( istream& ); // reads name from stream // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // name has been read from inStream and assigned to nameData // RETURNS // bool whether read and assignment were successful // CALLS // none // CALLED BY // readAll // ACCESSORS: virtual bool flag() const { return flagData; } // returns flagData, to signal whether this is in use bool operator ==( const string MATCH ) const { return emailData == MATCH; } // flags whether email address matches MATCH bool operator ==( const studentClass& STUDENT ) const { return( nameData == STUDENT.nameData && emailData == STUDENT.emailData ); } // checks whether two studentClasses are equal string print() const; // prints out student info // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string containing correctly formatted student info // CALLS // none // CALLED BY // commandClass string emailEcho() const { return emailData; } // returns emailAddress, unformatted // the following accessors return the fields in correct format for output: virtual string phone() const { return "Phone Number:\n\t" + phoneData + '\n'; } virtual string email() const { return "Email:\n\t" + emailData + '\n'; } virtual string other() const { return "Other:\n\t" + otherData + '\n'; } virtual string name() const { return "Name:\n\t" + nameData + '\n'; } virtual string address() const { return "Address:\n" + addressData + '\n'; } // CONSTRUCTORS: studentClass(); // default constructor // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // this is initialized with blank data // RETURNS // none // CALLS // none // CALLED BY // commandClass studentClass( istream& ); // constructor that reads a stream into an item // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // this is initialized with data from inStream // RETURNS // none // CALLS // none // CALLED BY // none }; bool operator >>( istream&, studentClass& ); // reads into a studentClass from a stream // PARAMETERS: // istream& inStream stream with data // studentClass& student to be read into // PRE-CONDITIONS // none // POST-CONDITIONS // data has been read from inStream and assigned appropriately to fields in student // RETURNS // bool whether read was successful // CALLS // studentClass::readAll // CALLED BY // commandClass bool operator <<( ostream&, const studentClass& ); // inserts item info into a stream // PARAMETERS: // ostream& outStream // const studentClass STUDENT // PRE-CONDITIONS // none // POST-CONDITIONS // STUDENT's info has been inserted into outStream in correct format // RETURNS // bool whether operation was successful // CALLS // studentClass::print // CALLED BY // commandClass #endif