Question: [Java code] Look at the following description for a package of Java classes used as a document checker. The package is used to open, decode

[Java code]

[Java code] Look at the following description for a package of Java

classes used as a document checker. The package is used to open,

decode and process documents in a number of different file formats, for

example docx or ASCII text. For each document the package needs to

be able to: Load and decode the document from a file Count

the words in the document Spell check the document returning a list

Look at the following description for a package of Java classes used as a document checker. The package is used to open, decode and process documents in a number of different file formats, for example docx or ASCII text. For each document the package needs to be able to: Load and decode the document from a file Count the words in the document Spell check the document returning a list of the words that it thinks are in error and for each word, its line and column number in the document. The code should support the following methods and attributes: . String lines[]; // Contents of the document void open() // Tries to open the document for processing It then processes the document into an array of Strings and stores them in attribute lines (see above) Each string is a line in the document. This open method will throw an exception if the file does not exist The format of the document will be described by the extension of the file name, so a file named essay.pdf will be in the portable document format. The filename will be passed to the Document class when constructing new instances of documents. The Document class type will support the following methods. String [] decodeDocument(InputStream inputStream) // Reads the document from the input stream and decodes it into lines of text int countWords() // Returns the number of words in the document SpellingMistakes [] spellcheck() // Spell checks the document and returns the mistakes. Spelling Mistake is a class partially defined as follow public class SpellingMistake { private String word; // word in question private int row; // row position in document private int column; // column position in document } Please provide a Java solution to this problem using the Factory object pattern. The SpellingMistake class needs completing with constructors, getters and setters as part of your solution. In your answer include a description of the Factory pattern [6 Marks] and code implementation of your solution to the problem written in Java. [24 Marks] In your code you should use the Faade structure and provide access to the spell checking service using a singleton class called SpellChecker. The code examples do not have to show the internal workings of the methods that involve decoding the documents or performing the spell checking. For your solution assume there are 3 document formats, pdf, docx and txt. Your factory class should produce an instance of a different concrete class for each format. Make sure your solution correctly follows the Myers open/closed principle. Hint as part of your solution, you will need an interface definition, an abstract class definition and 3 concrete class definitions

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!