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     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;

/**
 * <code>Words</code> represents a list of <code>Word</code> objects.
 */
class Words
{
    /** The Words */


    /**
     * Constructs a <code>Words</code> object.
     * @param wordList the words for the <code>Words</code> object.
     */
    public Words(String[] wordList)
    {
    }

    /**
     * Counts the number of words with <code>num</code> characters
     * @param num the number of characters
     * @return the number of words with <code>num</code> characters
     */
    public int countWordsWithNumChars(int num)
    {
        return -999;    // Replace
    }

    /**
     * Removes the words with <code>num</code> characters
     * from <code>this</code>
     * @param num the number of characters of words to be removed
     */
    public void removeWordsWithNumChars(int num)
    {
    }

    /**
     * Counts the number of words with <code>num</code> vowels
     * @param num the number of vowels
     * @return the number of words with <code>num</code> vowels
     */
    public int countWordsWithNumVowels(int num)
    {
        return -999;    // Replace
    }

    /**
     * Makes an array containing reversed <code>Word</code> objects.
     * Each of the items in the returned array is the reverse of an
     * item in <code>words</code>.  The items in the returned array
     * are in the same order as in <code>words</code>.
     * @return an array of the reverse objects of <code>words</code>.
     */

    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
    }
}
Words test2- new words(new String[] {
"fun", "fly", "four", "six", "times", "ten", "plus",
"eight"));
System.out.println("Words test2:+test2);
System.out.println("Number of words with 2 vowels: +
(2));
System.out.println("Number of words with 3 vowels: +
test2.countWordswithNumVowels (3));
System.out.println("Number of words with 4 vowels: *+
test2.countWordswithNumVowels (4));
test2.countWordswithNumVowels
System.out.println("Number of words with 2 chars: "+
test2.countwordskithNunChars (2));
System.out.println("Number of words with 4 chars: "+
test2.countWordswithNunChars (4));
System.out.println("Number of words with 5 chars: "
test2.countWordswithNunChars (5));
test2.removekordsWithNumChars (3);
System.out.println("\nwords test2 after removing words " +
with 3 chars:\"+test2);
System.out.println("\nReversed words: \n" +
System.out.println("\n\n");
Arrays.tostring(test2.getReversedwords()));
Words test3-new words(new String[] {
"alligator", "chicken", "dog", "cat", "pig", "buffalo"));
System.out.println("Words test3:+test);
System.out.println("Number of words with 2 vowels:+
test3.countWordswithNuVowels (2));
System.out.println("Number of words with 3 vowels: +
test3.countWordswithNumVowels (3));
System.out.println("Number of words with 4 vowels: +
test3.countwordswithNueVowels (4));
System.out.println("Number of words with 2 chars: "
test3.countWordswithChars (2));
System.out.println("Number of words with 4
test3.countWordswithNunChars (4));
System.out.println("Number of words with 9 chars:+
test3.countWordswithNunChars (9));
"/
chars: "+
test3.removebordswithusChars (3);
System.out.println("\nWords test3 after removing words " +
"with 3 chars:\n" + test3);
System.out.println("\nReversed words: \n" +
Arrays.tostring(test3.getReversedwords()));
Transcribed Image Text:Words test2- new words(new String[] { "fun", "fly", "four", "six", "times", "ten", "plus", "eight")); System.out.println("Words test2:+test2); System.out.println("Number of words with 2 vowels: + (2)); System.out.println("Number of words with 3 vowels: + test2.countWordswithNumVowels (3)); System.out.println("Number of words with 4 vowels: *+ test2.countWordswithNumVowels (4)); test2.countWordswithNumVowels System.out.println("Number of words with 2 chars: "+ test2.countwordskithNunChars (2)); System.out.println("Number of words with 4 chars: "+ test2.countWordswithNunChars (4)); System.out.println("Number of words with 5 chars: " test2.countWordswithNunChars (5)); test2.removekordsWithNumChars (3); System.out.println("\nwords test2 after removing words " + with 3 chars:\"+test2); System.out.println("\nReversed words: \n" + System.out.println("\n\n"); Arrays.tostring(test2.getReversedwords())); Words test3-new words(new String[] { "alligator", "chicken", "dog", "cat", "pig", "buffalo")); System.out.println("Words test3:+test); System.out.println("Number of words with 2 vowels:+ test3.countWordswithNuVowels (2)); System.out.println("Number of words with 3 vowels: + test3.countWordswithNumVowels (3)); System.out.println("Number of words with 4 vowels: + test3.countwordswithNueVowels (4)); System.out.println("Number of words with 2 chars: " test3.countWordswithChars (2)); System.out.println("Number of words with 4 test3.countWordswithNunChars (4)); System.out.println("Number of words with 9 chars:+ test3.countWordswithNunChars (9)); "/ chars: "+ test3.removebordswithusChars (3); System.out.println("\nWords test3 after removing words " + "with 3 chars:\n" + test3); System.out.println("\nReversed words: \n" + Arrays.tostring(test3.getReversedwords()));
import java.util.Arrays;
Application to test the <code>Mord</code> and
* <code>Words</code> classes.
"/
public class MordTester
(
public static void main(String[] args)
[
// Test Word
Word one new word("chicken");
System.out.println("Word one: + one);
System.out.println("Number
System.out.println("Number
System.out.println("Reverse:
System.out.println("\n\n");
of chars: "+one.getLength());
of vowels: +one.getNumVowels());
" + one.getReverse());
Word two new Word("alligator");
System.out.println("Word
System.out.println("Number
System.out.println("Number
two: " + two);
of chars:
of vowels:
two.getLength());
two-getNueVowels());
System.out.println("Reverse: "two-getReverse());
System.out.println("\n\n");
Word three new Word("elephant");
System.out.println("Word three: + three);
of chars:
of vowels:
System.out.println("Number
System.out.println("Number
System.out.println("Reverse:
System.out.println("\n\n");
" + three-getReverse());
three.getLength());
three.getNuVowels());
// Test Words
Words testi- new words(new String[] (
"one", "two", "three", "four", "Five", "six", "seven",
"alligator"));
System.out.println("Words testi: " + testi);
System.out.println("Number of words with 2 vowels: +
testi.countWordswithNumVowels (2));
System.out.println("Number of words with 3 vowels: *+
testi.countWordswithNumVowels (3));
System.out.println("Number of words with 4 vowels: +
testi.countWordswithNumVowels (4));
System.out.println("Number of words with 2 chars: a
testi.countWordswithNunChars (2));
System.out.println("Number of words with 4 chars:+
testi.countWordswithChars (4));
System.out.println("Number of words with 5 chars: " +
testi.countWordswithNunChars (5));
testi.removekordsWithNunChars (3);
System.out.println("\nWords testi after removing words +
with 3 chars:\"+testi);
System.out.println("\nReversed words: \n" +
System.out.println("\n\n");
Arrays.tostring(test1.getReversedwords()));
Transcribed Image Text:import java.util.Arrays; Application to test the <code>Mord</code> and * <code>Words</code> classes. "/ public class MordTester ( public static void main(String[] args) [ // Test Word Word one new word("chicken"); System.out.println("Word one: + one); System.out.println("Number System.out.println("Number System.out.println("Reverse: System.out.println("\n\n"); of chars: "+one.getLength()); of vowels: +one.getNumVowels()); " + one.getReverse()); Word two new Word("alligator"); System.out.println("Word System.out.println("Number System.out.println("Number two: " + two); of chars: of vowels: two.getLength()); two-getNueVowels()); System.out.println("Reverse: "two-getReverse()); System.out.println("\n\n"); Word three new Word("elephant"); System.out.println("Word three: + three); of chars: of vowels: System.out.println("Number System.out.println("Number System.out.println("Reverse: System.out.println("\n\n"); " + three-getReverse()); three.getLength()); three.getNuVowels()); // Test Words Words testi- new words(new String[] ( "one", "two", "three", "four", "Five", "six", "seven", "alligator")); System.out.println("Words testi: " + testi); System.out.println("Number of words with 2 vowels: + testi.countWordswithNumVowels (2)); System.out.println("Number of words with 3 vowels: *+ testi.countWordswithNumVowels (3)); System.out.println("Number of words with 4 vowels: + testi.countWordswithNumVowels (4)); System.out.println("Number of words with 2 chars: a testi.countWordswithNunChars (2)); System.out.println("Number of words with 4 chars:+ testi.countWordswithChars (4)); System.out.println("Number of words with 5 chars: " + testi.countWordswithNunChars (5)); testi.removekordsWithNunChars (3); System.out.println("\nWords testi after removing words + with 3 chars:\"+testi); System.out.println("\nReversed words: \n" + System.out.println("\n\n"); Arrays.tostring(test1.getReversedwords()));
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education