Hi all, need quick help on understanding the steps. I have added some code to start step 1 and hopefully everything looks good but on step 2 is where Im getting confused or having a little bit of problem understanding. Any help is appreciated!
Here are the steps!
1. Create a class called FormLetterTemplateFileReader which has the following methods:
A no-parameter constructor, which simply creates a FormLetterTemplateFileReader
A constructor which takes a file name
A setFile method which takes a file name, representing the file to read the FormLetter contents from
A readLine method which returns one line read from the opened (and buffered) file
A getTokens method which returns an array of tokens found on the line. A token is either a buffer of text, or a replacement data item. These data items are recognized by starting with a < and ending with a > .
Note that the FormLetterTemplateFileReader may store the array differently, internally; but it needs to return the result as an array of Strings. The Strings will be tokenized and constructed into a FormLetter by the FormLetterFile.
A way to
test the class to ensure it works properly (e.g., read a file, and output the resulting tokens). This can be a main method, or can be
JUnit tests.
Create a class called FormLetterFile which encapsulates a simple main method (not very different than FormLetterHello in many ways):
Here is the my code I did for Step 1
2. Gets two filenames from the command line or by prompting the user (implement one of the choices)
One filename is for the FormLetter, and one for the Properties.
Creates a new FormLetterFileReader using this filename as a parameter.
Creates a FormLetter instance with the filename as the title
While it can read a line from the FormLetterFileReader:
Break the line into tokens
For each token, if it is a simple
string (i.e., doesn't begin with a <, add it as a text entry to the FormLetter.
Otherwise, add it as a data item entry to the FormLetter.
Note that various text methods, such as trimming and substrings will be needed to make this go smoothly.
Load a Properties with the contents of the associated file name.
Invoke the doFormLetter method on the FormLetter.
Here is the started code for step 2, so far that is all I have done. I just have confusing on the steps, maybe just not reading them correctly.