Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************
- Author: Dr. Daniel Spiegel, Updated by: Trisha Badlu
- Creation Date: 19 April 2017
- Due Date: 26 April 2017
- Assignment: #4
- Filename: WordRec.h
- Course: CSC136 - 020
- Professor Name: Dr. Spiegel
- Purpose: The purpose of this file is to declare the
- prototypes for each of the member functions of
- the WordRec class.
- ***************************************************************/
- // File: WordRec.h
- // A WordRec holds a word and an int that can be used to track its multiplicity.
- #ifndef WORDREC_H
- #define WORDREC_H
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <fstream>
- using namespace std;
- class WordRec {
- public:
- // WordRec Constructor
- WordRec(string word="",int count=0);
- //Sets
- /*************************************************************************
- Function name: setWord (mutator)
- Description: Sets the object's word to the specified string
- Parameters: string - words (import)
- Return Value: none
- *************************************************************************/
- void setWord(string words);
- /*************************************************************************
- Function name: setCount (mutator)
- Description: Sets the object's count to the specified integer
- Parameters: int - counts (import)
- Return Value: none
- *************************************************************************/
- void setCount(int counts);
- //Gets
- /*************************************************************************
- Function name: getWord (inspector)
- Description: Returns the word stored in the specified WordRec
- Parameters: None
- Return Value: string - word
- *************************************************************************/
- string getWord() const;
- /*************************************************************************
- Function name: getCount (inspector)
- Description: Returns the count stored in the specified WordRec
- Parameters: None
- Return Value: int - count
- *************************************************************************/
- int getCount() const;
- /*************************************************************************
- Function name: operator++ (mutator)
- Description: Returns the pre-incremented word count
- Parameters: None
- Return Value: WordRec - *this
- *************************************************************************/
- WordRec &operator++();
- /*************************************************************************
- Function name: operator++ (mutator)
- Description: Returns the post-incremented word count
- Parameters: None
- Return Value: WordRec - temp
- *************************************************************************/
- WordRec operator++(int);
- /*************************************************************************
- Function name: operator-- (mutator)
- Description: Returns the pre-decremented word count
- Parameters: None
- Return Value: WordRec - *this
- *************************************************************************/
- WordRec &operator--();
- /*************************************************************************
- Function name: operator-- (mutator)
- Description: Returns the post-decremented word count
- Parameters: None
- Return Value: WordRec - temp
- *************************************************************************/
- WordRec operator--(int);
- /*************************************************************************
- Function name: operator() (mutator)
- Description: Returns a substring of a data member word
- Parameters: int - number (import)
- Return Value: string - getWord().substring(0,num)
- *************************************************************************/
- string operator()(int number) const;
- /*************************************************************************
- Function name: operator< (facilitator)
- Description: Checks if a WordRec's word is less than another WordRec's
- word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if less than)
- false (if greater than or equal to)
- *************************************************************************/
- bool operator<(const WordRec &right) const;
- /*************************************************************************
- Function name: operator<= (facilitator)
- Description: Checks if a WordRec's word is less than
- or equal to another WordRec's word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if less than or equal to)
- false (if greater than)
- *************************************************************************/
- bool operator<=(const WordRec &right) const;
- /*************************************************************************
- Function name: operator> (facilitator)
- Description: Checks if a WordRec's word is greater than another
- WordRec's word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if greater than)
- false (if less than or equal to)
- *************************************************************************/
- bool operator>(const WordRec &right) const;
- /*************************************************************************
- Function name: operator>= (facilitator)
- Description: Checks if a WordRec's word is greater than another
- WordRec's word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if greater thanor equal to)
- false (if less than)
- *************************************************************************/
- bool operator>=(const WordRec &right) const;
- /*************************************************************************
- Function name: operator== (facilitator)
- Description: Checks if a WordRec's word is equal to another WordRec's
- word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if equal to)
- false (if less than or greater than)
- *************************************************************************/
- bool operator==(const WordRec &right) const;
- /*************************************************************************
- Function name: operator!= (facilitator)
- Description: Checks if a WordRec's word is not equal to another
- WordRec's word
- Parameters: const WordRec& - right (import/export)
- Return Value: bool - true (if not equal to)
- false (if equal to)
- *************************************************************************/
- bool operator!=(const WordRec &right) const;
- private:
- //Contains a word from a file
- string word;
- //Contains the multiplicity of a word from a file
- int count;
- };
- /*************************************************************************
- Function name: operator<< (facilitator)
- Description: Prints out the word and it's count of each WordRec
- Parameters: ostream& - out (import/export)
- const WordRec& - right (import/export)
- Return Value: ostream& - out
- *************************************************************************/
- ostream &operator<<(ostream &out, const WordRec &right);
- /*************************************************************************
- Function name: operator<<= (facilitator)
- Description: Prints out the word of each WordRec
- Parameters: ostream& - out (import/export)
- const WordRec& - right (import/export)
- Return Value: ostream& - out
- *************************************************************************/
- ostream &operator<<=(ostream &stream, const WordRec &right);
- /*************************************************************************
- Function name: operator>> (facilitator)
- Description: Reads the file's input as a WordRec instead of a string
- Parameters: ifstream& - inf (import/export)
- WordRec& - right (import/export)
- Return Value: ifstream& - inf
- *************************************************************************/
- ifstream &operator>>(ifstream &inf, WordRec &right);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement