//------------------------------------------ // File: WordCount.H // Project: CMSC 202 Project 1 Spring 2003 // Author: Dennis L. Frey // Date: Feb 01, 2003 // SSN: xxx-xx-9999 // Section: 123 // Email: frey@cs.umbc.edu // // This file defines the WordCount class to // be used by students in project 1. // The WordCount class stores a string // and an integer and provides appropriate // access to the data. // // Note that the string stored in a WordCount // object cannot be changed. //-------------------------------------------- //----------------------------------------- // Note to the student // // When used for project 1, the // string will be a word read from the file // and the integer will be the number of // times the word appears in the file. //----------------------------------------- #ifndef WORDCOUNT_H #define WORDCOUNT_H #include using namespace std; class WordCount { public: //---------------------------------------- // Method: Default Constructor // PreCondition: none // PostCondition: // a new WordCount object is created with // an empty string and a count of 1 //---------------------------------------- WordCount ( void ); //-------------------------------------- // Method: Constructor // PreCondition: none // PostCondition: // a new WordCount object is created // containing the user-specified word and a count of 1 //---------------------------------------- WordCount (string word); //-------------------------------------- // Method: GetWord -- an accessor // PreCondition: none // PostCondition: // returns the word stored in the object // note that word is not changeable //---------------------------------------- const string& GetWord ( void ) const; //-------------------------------------- // Method: GetCount -- an accessor // PreCondition: none // PostCondition: // returns the current value of the count //---------------------------------------- int GetCount ( void ) const; //-------------------------------------- // Method: SetCount -- an accessor // PreCondition: none // PostCondition: // changes the count to the value // of the parameter newCount //---------------------------------------- void SetCount (int newCount); //-------------------------------------- // Method: IncrementCount -- a mutator // PreCondition: none // PostCondition: // increments the count by 1 //---------------------------------------- void IncrementCount (void); //-------------------------------------- // Method: DecrementCount -- a mutator // PreCondition: none // PostCondition: // decrements the count by 1 //---------------------------------------- void DecrementCount (void); private: string m_word; int m_count; }; #endif