Project 5: Word List In this Java programming assignment, you will practice using data structures in order to manage a list of words. To help you get started, I have provided some starter code, which...


jdoodle.com/a/2uzf








Project 5: Word List In this Java programming assignment, you will practice using data structures in order to manage a list of words. To help you get started, I have provided some starter code, which is detailed in steps I, II, and III. I. Design a class called WordList in a file called WordList.java. This class will hold two instance variables, the main method, a constructor, and five class methods that you will write in this assignment. II. I have provided the public static void main(String[] args) method for you to use. You can use and alter the main method to test your WordList class, by writing code that manipulates the WordList and utilizes the methods of the WordList class. I will not use your main method to test your program. III. I have created two instance variables for your class. The first variable is a String array called words. This will hold all of the words that are included in the WordList. The second variable is an integer called count. The words variable and the count variable will be initialized in the WordList constructor. You can use words and count in all of your methods without providing them as parameters to the method. IV. Write a constructor method for the WordList class. This method should create an array of size 2 and assign it to the words instance variable. The count variable should also be initialized to zero. V. Write three of the following five methods (addWord, removeWord, findWord). Hint: You do not have to write these methods in this order, and you may want to use some of these methods to complete the definitions of other methods (for instance, you can use findWord within addWord to decide whether or not it should be added). a. The method addWord should take a String argument and return an integer. This method should be designed to place a new word into the words array. To do this, you must consider the following cases: (1) the word is already in the list and does not need to be added; (2) the array is full, and you will need to double the array capacity before adding your word; (3) there is space in the array, and the word has not been previously included, so it can be added to the next open position in the array. In all cases, this method should return the number of words in the words array. b. The method removeWord should take a String argument and return nothing. This method should be designed to search for the given word and remove it if necessary. To remove a word from the list, the value should be overwritten, and all words appearing to the right within the array should be moved back one place. The count should then be adjusted accordingly. c. The method findWord should take a String argument and return an integer. This method should be designed to iterate over each word in the current list, and return the index of the word if found. If the word is not found, this method should return -1. d. The method equals has been provided for you. It tests to see if two WordList items are the same. e. The method toString, has been provided for you. This method will be called whenever the WordList object is referenced in code where a String is expected.  There are 3 words in the word list: Dog Cat Fish VI. Submit your WordList.java file on Blackboard. This is a challenging assignment, which extends beyond the scope of those that have come before it. Below you will find an example set of WordList method invocations that should be viewed as being called successively. Appearing in the columns next to the method call are the values of the two instance variables and the return value of the method call. This should be used to aid the clarity of the program specifications. Good luck! Method invocation Return value words count WordList w1 = new WordList(); WordList reference {“”,””} 0 w1.addWord(“computer”); 1 {“computer”,””} 1 w1.addWord(“abacus”); 2 {“computer”,”abacus”} 2 w1.addWord(“computer”); 2 {“computer”,”abacus”} 2 w1.removeWord(“computer”); None {“abacus”,”abacus”} (Note: abacus is shifted to overwrite computer, but old data is not erased) 1 System.out.println(w1); “There is 1 word in the word list:\nabacus\n” {“abacus”,”abacus”} 1 WordList w2 = new WordList(); WordList reference {“”,””} 0 w1.equals(w2); false w1 {“abacus”,”abacus”} w2 {“”,””} 1 0 w2.addWord(“abacus”); 1 {“abacus”,””} 1 w1.equals(w2); true w1 {“abacus”,”abacus”} w2 {“abacus”,””} 1 0 w1.addWord(“dog”); 2 {“abacus”,”dog”} 2 w1.addWord(“cat”); 3 {“abacus”,”dog”,”cat”,””} 3 w1.removeWord(“abacus”); None {“dog”,”cat”,”cat”,””} 2 Project 5: WordList Rubric I. Completion Tasks (6) a. WordList.java compiles   II.Correctness (42 pts) a. findWord method returns the correct values. (10) b. addWord method adds new word to array (5) c. addword makes sure word does not already exist on list (3) d. Addword changes size of array when it becomes full and restore values (8) e. Correctly keep count of words, not spaces in the list (3) f. removeWord deletes the given word (5) g. removeWord Moves all words after the removed word up the list, it is ok to have a repeating last item. (5) H. correctly keeps count of unique items on the list.(3) TOTAL: 6 + 42 = 48 pts   USE THIS STARTER CODE DO NOT GET RID OR CHANGE OF ANY OF IT!!! Starter code:  jdoodle.com/a/2uzf
Oct 28, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here