Question: Write the definition of a class named Dictionary whose state is an ArrayList of words (Strings). The Dictionary classoffers one constructor and one method, found

Write the definition of a class named Dictionary whose state is an ArrayList of words (Strings). The Dictionary classoffers one constructor and one method, found. The constructor gets the name of a file and reads all the words in the file, converting them to lower case to initialize the ArrayList (it will have to create the ArrayList too). The method, found, recieves one argument, a String, and returns true if and only if the word argument, when converted to lower case, can be found in the ArrayList of the Dictionary object.

Then, write a program named SpellCheck2 that creates a Dictionary object (based on a file named "Dictionary") and then reads a file named paper line by line, keeping count of the line numbers as it does. With each line, the programexamines every word in the line (hint: use a Scanner based on the String holding the line). For each word in the line, the program invokes the found method in the Dictionary object. If found returns true (i.e. the word is found in the object), then the word is spelled correctly and no action is taken. Otherwise, the program displays the line number and the word to standard output (thus indicating the spelling error and where it occurred). The format of the output line is this: first "Line " literally. Then the line number displayed in a field of FOUR positions. Then, a colon and a space... and finally the misspelled word itself. For example:

Line 47: neccesary

Note: the file named "Dictionary" is read only once, at the beginning of the program, by the constructor of the one Dictionary object being created.

Submit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!