Scanner.java for 1.4
For this take-home we're using an example from Chapter 3 of the book The Practice of Programming by Kernighan and Pike. I handed out this chapter in class on Wednesday, and extra copies of it are outside my door. A Model/View framework for creating a Markov program like the one discussed in that chapter, and based on the model/view code we've used in Compsci 100 is snarfable from the class snarf-site at http://www.cs.duke.edu/courses/cps108/fall05/snarf (use this in your Eclipse/Snarf window) you can also browse the .java files in the code directory.
For the take-home test/coding you are to implement the Markov example described in the chapter. You should use the provided MarkovModel class as the analog of what's called the Markov class in the chapter. The book includes a complete implementation and discussion of the code to generate random text based on digram word frequencies (two words used to predict the next word). You're to implement a program for this, but you should adapt the code in the book as you see fit and according to principles we've discussed and covered in class. If you can make the code general enough to support trigram frequencies so that this can be chosen (e.g., from a menu option) at runtime, you'll get extra bonus points (but no certificate).
For example, the class Prefix in the book includes public data. This isn't in keeping with OO information-hiding principles. The book also uses Collection classes like Vector and Hashtable that should be replaced by the more modern Java equivalents of ArrayList (or a more general List) and HashMap (again, or more generally Map).
You should document design decisions you make and why you've made them in a README file that you submit with your code. Your grade will be based 30% on whether the code runs as specified, 30% on the architecture/design/coding style you use, and 40% on the reasons and justifications you provide for your coding/design decisions. This means you should allocate real time for the README and not treat it as a last-five-minute task.
You should include appropriate javadoc comments for all classes and methods that you write, this is part of the 30% coding style grade.
You may change any of the code you're given, but you must provide a class named MarkovMain that can run your program and you must supply a class MarkovModel that extends an unmodified AbstractModel class -- we may test your program by using it only via its IModel interface.