/*************************************************************************************** * Filename: WordRec.h * Author: Dr. Daniel Spiegel with documentation completeted by * Deadline: * Date of Submission: * Course: CSc 136 * Professor: Dr. Daniel Spiegel * Assignment: Project #2 * Description Project: Creation and Implementation of an Object Type Alphabetically organize the first N unique words in a file, taking note of their multiplicities. File: Definition of WordRec object-type class, a container of a token and its multiplicity ****************************************************************************************/ // File: WordRec.h // Author: Dr. Spiegel // Last Revision; Feb 6 2022 // A WordRec is a container used to track a word and its multiplicity in data #ifndef WORDREC_H #define WORDREC_H #include #include #include #include using namespace std; class WordRec { public: /********************************************************************************** * Function name: * Description: * Member Type: * Parameters: * Returns: ***********************************************************************************/ WordRec(string word="",int times=1); //Sets the WordRec's data member word void setWord(string token); /********************************************************************************** * Function name: getWord * Description: Furnishes the value of the word data member. * Member Type: Inspector * Parameters: None * Returns: string - the value held in the word data member ***********************************************************************************/ string getWord() const; /********************************************************************************** * Function name: * Description: * Member Type: * Parameters: * Returns: ***********************************************************************************/ int getCount() const; /********************************************************************************** * Function name: * Description: ++ overload(Pre and Post): Increments count data member * Member Type: * Parameters: * Returns: ***********************************************************************************/ WordRec &operator++(); WordRec operator++(int); /********************************************************************************** * Function name: * Description: * Member Type: * Parameters: * Returns: ***********************************************************************************/ //Operator < overload: // Returns whether a WordRec's word is alphanumerically less than another // WordRec's word bool operator<(const WordRec &right) const; /********************************************************************************** * Function name: Operator == overload * Description: Returns whether a WordRec's word is equal to another WordRec's word * Member Type: * Parameters: * Returns: ***********************************************************************************/ bool operator==(const WordRec &right) const; private: // Holds a token string word; // The multiplicity of the token int count; /********************************************************************************** * Function name: * Description: * Member Type: * Parameters: * Returns: ***********************************************************************************/ //Sets the WordRec data member count (why private?) void setCount(int value); }; /********************************************************************************** * Function name: Operator << overload * Description: Inserts a WordRec object into an output stream * Parameters: * Returns: ***********************************************************************************/ ostream &operator<<(ostream &out, const WordRec &right); /********************************************************************************** * Function name: * Description: Inputs token from file into a WordRec object; sets initial count * Parameters: ifstream &inf - import/export WordRec &right - export only * Returns: ***********************************************************************************/ //Operator >> overload: ifstream &operator>>(ifstream &inf, WordRec &right); #endif