Question: #include #include #include #include WordData.h using namespace std; int main() { cout 1. 2 Create a New Project and give your project the name Labo.
#include#include #include #include "WordData.h" using namespace std; int main() { cout ![]()


1. 2 Create a New Project and give your project the name Labo. In this lab, you are required to create a class WordData that has the following features, A WordData object should be able to store a character string and a number of integers representing the number of vowels, the number of consonants, the number of digits and the number of special characters in the character string. It also consists of a number of functions to manipulate the data The UML class diagram is given below: WordData word : char* vowels : int consonants : int digits : int specialChars: int WordData() - WordData() setWord(const string& inWord): void getWord() const: string displayData() const:void + where word: a data member to store a string represented in character string vowels: a data member to store the number of vowels in "word" consonants: a data member to store the number of consonants in word" digits: a data member to store the number of digits in "word" specialChars: a data member to store the number of special characters in "word" WordData(): a default constructor that sets the word to new charf!): with word/01 - "0; Also it sets all the remaining data members to 0. Note: Visa sharacter, wlush espresents the sad of achataster string. WordData(): a destructor, which relcases the memory allocated for "word" (More details about destructor will be given later in lectures) set Word(const string& in Word): a mutator function that performs the following: a) Allocate memory space to store the string associated with in Word (You can use string member function "size()" to determine the length of in Word. Also, you are reminded to allocate memory space for the character "", which should be put at the end of the string.) b) Count the number of vowels in in Word (a, e, i, o, or u) c) Count the number of consonants in in Word (letters that are not vowels) d) Count the number of digits in in Word (0. 1. 2. 3. 4. 5. 6. 7. 8. or 9) e) Count the number of "special characters in in Word (characters that do not fall in any of Faculty of Science and Technology (FST), Low College Hong Kong 5 the other categories) Note: The ASCILrange of A to Z* is 65 to 90.**to*z is 97 to 122. range of O'*9* is 48 getWord(): an inspector function (a CONSTANT member function as well) that returns the character string as a C++ string. Example to convert a char* to string: string str(charString): // where str is in string type, charString in char type displayData(): an output function (a CONSTANT member function as well that outputs a) Character string 'word" b) All the other data members in one line. Note: TWO TABs must be added after displaying the character array. ONE TAB in between cach of the remaining data 3. A main function (in main.cpp) has been provided for you to test out your class. The following is the sample output. Vowels Const. Digits Special Word This string has 15 words It has lots of letters and very few special chars! 1 1 1 0 1 1 1 1 1 1 2 3 1 5 2 3 2 OOONOOOOOOOOOOO 1 1 1 1 1. 2 Create a New Project and give your project the name Labo. In this lab, you are required to create a class WordData that has the following features, A WordData object should be able to store a character string and a number of integers representing the number of vowels, the number of consonants, the number of digits and the number of special characters in the character string. It also consists of a number of functions to manipulate the data The UML class diagram is given below: WordData word : char* vowels : int consonants : int digits : int specialChars: int WordData() - WordData() setWord(const string& inWord): void getWord() const: string displayData() const:void + where word: a data member to store a string represented in character string vowels: a data member to store the number of vowels in "word" consonants: a data member to store the number of consonants in word" digits: a data member to store the number of digits in "word" specialChars: a data member to store the number of special characters in "word" WordData(): a default constructor that sets the word to new charf!): with word/01 - "0; Also it sets all the remaining data members to 0. Note: Visa sharacter, wlush espresents the sad of achataster string. WordData(): a destructor, which relcases the memory allocated for "word" (More details about destructor will be given later in lectures) set Word(const string& in Word): a mutator function that performs the following: a) Allocate memory space to store the string associated with in Word (You can use string member function "size()" to determine the length of in Word. Also, you are reminded to allocate memory space for the character "", which should be put at the end of the string.) b) Count the number of vowels in in Word (a, e, i, o, or u) c) Count the number of consonants in in Word (letters that are not vowels) d) Count the number of digits in in Word (0. 1. 2. 3. 4. 5. 6. 7. 8. or 9) e) Count the number of "special characters in in Word (characters that do not fall in any of Faculty of Science and Technology (FST), Low College Hong Kong 5 the other categories) Note: The ASCILrange of A to Z* is 65 to 90.**to*z is 97 to 122. range of O'*9* is 48 getWord(): an inspector function (a CONSTANT member function as well) that returns the character string as a C++ string. Example to convert a char* to string: string str(charString): // where str is in string type, charString in char type displayData(): an output function (a CONSTANT member function as well that outputs a) Character string 'word" b) All the other data members in one line. Note: TWO TABs must be added after displaying the character array. ONE TAB in between cach of the remaining data 3. A main function (in main.cpp) has been provided for you to test out your class. The following is the sample output. Vowels Const. Digits Special Word This string has 15 words It has lots of letters and very few special chars! 1 1 1 0 1 1 1 1 1 1 2 3 1 5 2 3 2 OOONOOOOOOOOOOO 1 1 1 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
