Wyo Java Ch13Proj3

Create a class named Dictionary has an ArrayList of strings as a property and that includes the following methods:

  • void displayAll() - displays all words stored in the dictionary
  • boolean add(String word1) - adds a word to the dictionary. If word1 already exists in the dictionary, it must not be added a second time. True is returned if word1 was successfully added, false is returned if it was not added. Words are case-sensitive so "Cat" is a different word than "cat".
  • String getRandomWord() - returns a random word from the dictionary
  • boolean find(String word1) - returns true if word1 is found in the dictionary, false otherwise
  • boolean remove(String word1) - removes word1 in the dictionary and returns true if it was found, false is returned otherwise
  • int getNumWords() - returns the number of words in the dictionary
  • boolean findAndReplace(String word1, String word2) - finds the occurrence of word1 in the dictionary and replaces it with word2. True is returned if word1 was found and replaced successfully with word2, false is returned if word1 was not found and nothing was replaced. If word2 already is found in the dictionary, do not perform the replacement. Return false in that case.

Also, create a default constructor as well as a constructor that creates a new dictionary with one word specified as a parameter. Write a test class named DictionaryTest that thoroughly tests all of the methods and constructors. The test class must be adequately annotated so its easy for the instructor to see that all the methods work correctly. The test class must first allow the user to input as many words into the dictionary as he would like using Scanner. Your program must follow the class Coding Standards. Save all of the files associated with this assignment to a folder named Ch13Proj3 in the appropriate network folder.

Preconditions:

    • None

You must hand in the following on separate pages stapled in this specified order:

    1. The source code for the Dictionary class.
    2. The source code for the DictionaryTest class.
    3. The screen capture of your program's output.