The complete specification of assignment #4 can be found as part of the stream at iTunes.
Reading the lexicon from a data file
Part III of this assignment is by far the easiest and requires considerably less than half a page of code.
Your job in this part of the assignment is simply to reimplement the HangmanLexicon class so that instead of selecting from a meager list of ten words, it reads a much larger word list from a file. The steps involved in this part of the assignment are as follows:
- Open the data file HangmanLexicon.txt using a BufferedReader that will allow you to read it line by line.
- Read the lines from the file into an ArrayList.
- Reimplement the getWordCount and getWord methods in HangmanLexicon so that
they use the ArrayList from step 2 as the source of the words.
The first two steps should be done in a constructor for HangmanLexicon, which you will need to add to the file. The last step is simply a matter of changing the implementation of the methods that are already there.
Here is how the HangmanLexicon constructor should be added to the HangmanLexicon class:
Continue reading “cs106a – Assignment #4 – Task #3”