Question: oversize array of words. The perfect size array stored the common dictionary, which never changed, and the oversize array stored the personal dictionary, which had

oversize array of words. The perfect size array stored the common dictionary, which never changed, and the oversize array stored the personal dictionary, which had extra space for the user to add words. One problem with this approach is that the capacity of the oversize array is fixed. If the capacity is too small, the user will run out of space. If the capacity is too large, the program wastes memory. A better approach is to use an oversize array of moderate capacity (say, 10 elements), and if the user runs out of space, construct a new, larger array. This is exactly how the ArrayList class works. If an element is added to a full ArrayList, the existing elements are copied to a larger array with space for the new element. In this project, we will refactor the spell checker to use ArrayLists instead of arrays. This will require us to change the signature and body of each method. When we are finished, the program will work as it did before, but the code will be shorter and easier to understand, since the details of ArrayList objects are hidden (encapsulated) inside the ArrayList class. Objectives: Update the spell checker to use ArrayLists of Strings, rather than normal String arrays. The new version should include the changes listed below. 1. (20 points) Replace the methods readFilePerfect and read File Oversize with a single method named "readfile". This method reads a file with a given name and returns the lines in an ArrayList of Strings. If the file does not exist, readfile creates an empty text file with the given name. 2. (20 points) Refactor the method checkSpelling. The old method checks if a given String can be found in either of two arrays, one perfect size and the other oversize. The new method checks if the String can be found in either of two ArrayLists. 3. (20 points) Refactor the method writeFile. The old method writes each String in an oversize array to a file with a given name. The new method is given an ArrayList of Strings, rather than an oversize array. 4. (20 points) Refactor the main method. Store the common and personal dictionaries in ArrayLists instead of arrays. Call the refactored methods from objectives 1-3 in place of the old methods so that the program works exactly like the original version. (A user of the program will not be able to see a difference.) 5. (10 points) Remove any unnecessary import statements, local variables, and parameters from the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
