This project utilizes three new classes: · Word - an immutable class representing a word · Words - a class representing a list of Word objects · WordTester - a class used to test the Word and Words classes. WordTester (the application) is complete and only requires uncommenting to test the Word and Words classes as they are completed. The needed imports, class headings, method headings, and block comments are provided for the remaining classes. Javadocs are also provided for the Word and Words classes. Word The Word class represents a single word. It is immutable. You have been provided a skeleton for this class. Complete the Word class using the block comments, Javadocs, and the following instructions. 1. Add a String instance variable named word which will contain the word. 2. Complete the one parameter constructor to initialize the word instance variable. 3. Complete the getLength method to return the number of characters in the word. 4. Complete the getNumVowels method to return the number of vowels in the word. It should use the VOWELS class constant and String’s length, substring, and indexOf methods. Do not use more than one loop. Do not use any String methods that are not in the AP Subset. 5. Complete the getReverse method to return a Word with the letters of this reversed. 6. Complete the toString method to return the String word. 7. Uncomment the Word test code in WordTester and make sure that Word works correctly. Words The Words class represents a list of words. You have been provided a skeleton for this class. Complete the Words class using the block comments, Javadocs, and the following instructions. 1. Add a List instance variable named words which will contain the list of words. Be sure to specify the type of objects that will be stored in the List. 2. Complete the one parameter constructor to initialize the words instance variable. You will need to create the ArrayList and add each word to it. This would be a great place to use a for-each loop. Your code should not generate any warnings. 3. Complete the countWordsWithNumChars method to return the number of words with lengths of num characters. 4. Complete the removeWordsWithNumChars method to remove all words with lengths of num characters. 5. Complete the countWordsWithNumVowels method to return the number of words that have num vowels. 6. Complete the getReversedWords method to return an array of reversed words. 7. Complete the toString method to return the words as a String. You should utilize ArrayLists’s toString method. 8. Uncomment the Words test code in WordTester and make sure that Words works correctly. WORDS CLASS: import java.util.List; import java.util.ArrayList; /** * Words represents a list of Word objects. */ class Words { /** The Words */ /** * Constructs a Words object. * @param wordList the words for the Words object. */ public Words(String[] wordList) { } /** * Counts the number of words with num characters * @param num the number of characters * @return the number of words with num characters */ public int countWordsWithNumChars(int num) { return -999; // Replace } /** * Removes the words with num characters * from this * @param num the number of characters of words to be removed */ public void removeWordsWithNumChars(int num) { } /** * Counts the number of words with num vowels * @param num the number of vowels * @return the number of words with num vowels */ public int countWordsWithNumVowels(int num) { return -999; // Replace } /** * Makes an array containing reversed Word objects. * Each of the items in the returned array is the reverse of an * item in words. The items in the returned array * are in the same order as in words. * @return an array of the reverse objects of words. */ public Word[] getReversedWords() { return null; // Replace } /** * Gives the string representing the words. * @return the string representing the words. */ public String toString() { return null; // Replace } } WORD CLASS: public class Word { private static final String VOWELS = "AEIOUaeiou"; public Word(String w) { } public int getLength() { return -999; // Replace } public int getNumVowels() { return -999; // Replace } public Word getReverse() { return null; // Replace } public String toString() { return null; // Replace } }
This project utilizes three new classes:
· Word - an immutable class representing a word
· Words - a class representing a list of Word objects
· WordTester - a class used to test the Word and Words classes.
WordTester (the application) is complete and only requires uncommenting to test the Word and Words classes as they are completed. The needed imports, class headings, method headings, and block comments are provided for the remaining classes. Javadocs are also provided for the Word and Words classes.
Word
The Word class represents a single word. It is immutable. You have been provided a skeleton for this class. Complete the Word class using the block comments, Javadocs, and the following instructions.
1. Add a String instance variable named word which will contain the word.
2. Complete the one parameter constructor to initialize the word instance variable.
3. Complete the getLength method to return the number of characters in the word.
4. Complete the getNumVowels method to return the number of vowels in the word. It should use the VOWELS class constant and String’s length, substring, and indexOf methods. Do not use more than one loop. Do not use any String methods that are not in the AP Subset.
5. Complete the getReverse method to return a Word with the letters of this reversed.
6. Complete the toString method to return the String word.
7. Uncomment the Word test code in WordTester and make sure that Word works correctly.
Words
The Words class represents a list of words. You have been provided a skeleton for this class. Complete the Words class using the block comments, Javadocs, and the following instructions.
1. Add a List instance variable named words which will contain the list of words. Be sure to specify the type of objects that will be stored in the List.
2. Complete the one parameter constructor to initialize the words instance variable. You will need to create the ArrayList and add each word to it. This would be a great place to use a for-each loop. Your code should not generate any warnings.
3. Complete the countWordsWithNumChars method to return the number of words with lengths of num characters.
4. Complete the removeWordsWithNumChars method to remove all words with lengths of num characters.
5. Complete the countWordsWithNumVowels method to return the number of words that have num vowels.
6. Complete the getReversedWords method to return an array of reversed words.
7. Complete the toString method to return the words as a String. You should utilize ArrayLists’s toString method.
8. Uncomment the Words test code in WordTester and make sure that Words works correctly.
WORDS CLASS:
Step by step
Solved in 3 steps