SHARE
TWEET

Untitled

a guest Apr 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***************************************************************
  2. Author:     Dr. Daniel Spiegel, Updated by: Trisha Badlu
  3. Creation Date:  19 April 2017                            
  4. Due Date:   26 April 2017
  5. Assignment:     #4
  6. Filename:       WordRec.h                                  
  7. Course:     CSC136 - 020                                    
  8. Professor Name: Dr. Spiegel  
  9. Purpose:    The purpose of this file is to declare the
  10.         prototypes for each of the member functions of
  11.         the WordRec class.
  12. ***************************************************************/
  13. // File: WordRec.h
  14. // A WordRec holds a word and an int that can be used to track its multiplicity.
  15.  
  16. #ifndef WORDREC_H
  17. #define WORDREC_H
  18. #include <iostream>
  19. #include <iomanip>
  20. #include <string>
  21. #include <fstream>
  22.  
  23. using namespace std;
  24.  
  25. class WordRec {
  26.   public:
  27.  
  28.   // WordRec Constructor
  29.   WordRec(string word="",int count=0);
  30.  
  31.   //Sets
  32. /*************************************************************************
  33. Function name: setWord (mutator)                          
  34. Description: Sets the object's word to the specified string          
  35. Parameters: string - words (import)                                      
  36. Return Value: none            
  37. *************************************************************************/
  38.   void setWord(string words);
  39. /*************************************************************************  
  40. Function name: setCount (mutator)                                            
  41. Description: Sets the object's count to the specified integer    
  42. Parameters: int - counts (import)                                        
  43. Return Value: none                                    
  44. *************************************************************************/
  45.   void setCount(int counts);
  46.  
  47.   //Gets
  48. /*************************************************************************
  49. Function name: getWord (inspector)                                            
  50. Description: Returns the word stored in the specified WordRec      
  51. Parameters: None                                                    
  52. Return Value: string - word            
  53. *************************************************************************/
  54.   string getWord() const;
  55. /*************************************************************************
  56. Function name: getCount (inspector)    
  57. Description: Returns the count stored in the specified WordRec      
  58. Parameters: None                                                    
  59. Return Value: int - count                            
  60. *************************************************************************/
  61.   int getCount() const;
  62. /*************************************************************************  
  63. Function name: operator++ (mutator)                                            
  64. Description: Returns the pre-incremented word count                  
  65. Parameters: None                                                    
  66. Return Value: WordRec - *this                          
  67. *************************************************************************/
  68.   WordRec &operator++();
  69. /*************************************************************************  
  70. Function name: operator++ (mutator)                                            
  71. Description: Returns the post-incremented word count                
  72. Parameters: None                                                    
  73. Return Value: WordRec - temp                                            
  74. *************************************************************************/
  75.   WordRec operator++(int);
  76. /*************************************************************************    
  77. Function name: operator-- (mutator)                                            
  78. Description: Returns the pre-decremented word count                  
  79. Parameters: None                                                    
  80. Return Value: WordRec - *this                  
  81. *************************************************************************/
  82.   WordRec &operator--();
  83. /*************************************************************************  
  84. Function name: operator-- (mutator)                                            
  85. Description: Returns the post-decremented word count                
  86. Parameters: None                                                    
  87. Return Value: WordRec - temp                                  
  88. *************************************************************************/
  89.   WordRec operator--(int);
  90. /*************************************************************************    
  91. Function name: operator() (mutator)                                            
  92. Description: Returns a substring of a data member word                
  93. Parameters: int - number (import)                                
  94. Return Value: string - getWord().substring(0,num)                    
  95. *************************************************************************/
  96.   string operator()(int number) const;
  97. /*************************************************************************    
  98. Function name: operator< (facilitator)          
  99. Description: Checks if a WordRec's word is less than another WordRec's
  100.              word                                                    
  101. Parameters: const WordRec& - right (import/export)      
  102. Return Value: bool - true (if less than)                            
  103.                      false (if greater than or equal to)              
  104. *************************************************************************/
  105.   bool operator<(const WordRec &right) const;
  106. /*************************************************************************  
  107. Function name: operator<= (facilitator)                
  108. Description: Checks if a WordRec's word is less than
  109.          or equal to another WordRec's word                      
  110. Parameters: const WordRec& - right (import/export)            
  111. Return Value: bool - true (if less than or equal to)      
  112.                      false (if greater than)                
  113. *************************************************************************/
  114.   bool operator<=(const WordRec &right) const;
  115. /*************************************************************************
  116. Function name: operator> (facilitator)                          
  117. Description: Checks if a WordRec's word is greater than another
  118.          WordRec's word                              
  119. Parameters: const WordRec& - right (import/export)            
  120. Return Value: bool - true (if greater than)                            
  121.                      false (if less than or equal to)          
  122. *************************************************************************/
  123.   bool operator>(const WordRec &right) const;
  124. /*************************************************************************    
  125. Function name: operator>= (facilitator)                          
  126. Description: Checks if a WordRec's word is greater than another
  127.          WordRec's word                                    
  128. Parameters: const WordRec& - right (import/export)              
  129. Return Value: bool - true (if greater thanor equal to)              
  130.                      false (if less than)                        
  131. *************************************************************************/
  132.   bool operator>=(const WordRec &right) const;
  133. /*************************************************************************
  134. Function name: operator== (facilitator)                          
  135. Description: Checks if a WordRec's word is equal to another WordRec's
  136.              word                                      
  137. Parameters: const WordRec& - right (import/export)            
  138. Return Value: bool - true (if equal to)                              
  139.                      false (if less than or greater than)              
  140. *************************************************************************/
  141.   bool operator==(const WordRec &right) const;
  142. /*************************************************************************  
  143. Function name: operator!= (facilitator)                      
  144. Description: Checks if a WordRec's word is not equal to another
  145.          WordRec's word                                                    
  146. Parameters: const WordRec& - right (import/export)    
  147. Return Value: bool - true (if not equal to)                              
  148.                      false (if equal to)          
  149. *************************************************************************/
  150.   bool operator!=(const WordRec &right) const;
  151.  
  152.  
  153.   private:
  154.  
  155.   //Contains a word from a file
  156.   string word;
  157.   //Contains the multiplicity of a word from a file
  158.   int count;
  159. };
  160. /*************************************************************************  
  161. Function name: operator<< (facilitator)            
  162. Description: Prints out the word and it's count of each WordRec      
  163. Parameters: ostream& - out (import/export)          
  164.             const WordRec& - right (import/export)          
  165. Return Value: ostream& - out                              
  166. *************************************************************************/
  167. ostream &operator<<(ostream &out, const WordRec &right);
  168. /*************************************************************************    
  169. Function name: operator<<= (facilitator)          
  170. Description: Prints out the word of each WordRec      
  171. Parameters: ostream& - out (import/export)            
  172.             const WordRec& - right (import/export)          
  173. Return Value: ostream& - out                                                                        
  174. *************************************************************************/
  175. ostream &operator<<=(ostream &stream, const WordRec &right);
  176. /*************************************************************************  
  177. Function name: operator>> (facilitator)                  
  178. Description: Reads the file's input as a WordRec instead of a string
  179. Parameters: ifstream& - inf (import/export)              
  180.             WordRec& - right (import/export)                
  181. Return Value: ifstream& - inf                              
  182. *************************************************************************/
  183. ifstream &operator>>(ifstream &inf, WordRec &right);
  184.  
  185. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top