Question: C++ language : Classes: Part 2 Part II In this part of the assignment, you are to create a class, WordCounts. You will define some

C++ language: Classes: Part 2

C++ language: Classes: Part 2 Part II In this part of the

Part II In this part of the assignment, you are to create a class, WordCounts. You will define some class data members, member methods and helper functions. The class methods will be used keep a running count of the number of times each word is being used. You can assume that there will never be more than 10,000 unique words being counted. Your class will provide the following public methods to support counting word usage: void tallyWords(string sentence): This function will take in a string of multiple words, remove the punctuation, and increment the counts for all words in the string. If a word is not already in the list, add it to the list. This function is used to keep a running count of each unique word processed; that means multiple calls to the function should update the count of the words, not replace them. If we call the function three times: resetTally ); tallyWords ("the brown fox."); tallyWords ("the red fox.") tallyWords ("teh blue cat.") The count for the words "the" and "fox" should be 2, the count for the words "brown", "red", "blue", "cat", and "teh" should be 1 int getTally (string word): return the current count of the given word. If the word is not found to be in the current list of words, return 0 * void resetTallyO: reset all word counts to zero * int mostTimes(string words[|, int countsll, int n): find the n most common words in the text that has been counted and return those words and counts in via the arrays given as parameters. Assume the arrays are large enough to hold the number of elements requested. Testing Testing of your class and all of its methods is now in your hands. You must determine the test cases that will test if your implementation returns the correct results in all conditions. For example, you would need to write code that will declare WordCounts objects with each of the possible constructors, to verify that each of those methods will create and initialize the object correctly. The same must be done for each of the other public methods to verify that your implementation works correctly in all possible conditions and ordering of calls to those methods Once you are satisfied that your code works as intended, submit it to COG for its evaluation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!