A class project
Objectives
We would like to :- Develop and enhance our skills with classes.
Notes
- A simple text analysis tool would read in text from a file word by word and allow the user to examine the "distinct" words and how frequently each occurs. A word is a series of characters separated by white space. Words only include lower case alphabetic characters, so all other characters should be removed. All characters should be moved to lower case.
- What objects might be useful in such a program?
- A word-counter object
- data:
- The string or word.
- The count, or how many times the word occurred.
- methods:
- Create an instance, no parameter
- Create an instance given a "raw" string
- Compare two instances for equality
- Increment the number of words
- Add? two instances.
- Get the count
- Get the word
- Compare based on word <
- Compare based on count <
- data:
- A word-counter array
- A static array, this will be changed to a dynamic array later.
- Data:
- The number of elements stored from position 0 to size-1
- capacity, the total number of elements the array can hold
- A static array
- Methods:
- push_back
- size/length
- Constructor
- [] Operator?
- at operator()?
- A word-counter object
- Main algorithm:
-
Open the file while there are words in the file read in a word If the word is in the array, increment the count else if there is space in the array add the word to the array Close the file Print the array sorted alphabetically Print the array sorted numerically
-