Due date details | Overview | Starting code | Written part | Rules, advice, guidelines Hints, tips, and corrections Please check here occasionally! |
Part B solution -- see main homework page | Turn-in forms |
Due dates: Electronic parts are due on Wednesday evening, Feb. 12. Paperwork and written parts may be handed in on Feb. 13 in quiz section or Feb. 14 in lecture.
February is the month for urgent questions. What kind of chocolate is
just right for that special someone? What is my grade in CSE143 going to
be? Who will marry Joe Millionaire? Fortunately, a coffin maker
named E.C. Reiche discovered a simple way to channel spirits of the dead into answering
such questions. By 1890 the concept had developed into the Ouija board, still in
everyday use by decision-makers everywhere. Visit
Ghosts of the Prairie Haunted
Museum for more information Now, for the first time ever, the Ouija board is poised for two major breakthroughs -- and you are part of this history-making adventure. First -- the Ouija board enters the electronic age, by being reborn as a computer application. Every time you tap on the board, it spits out the next letter of the answer. Second, and most amazing -- the electronic Ouija board is totally multilingual. It can generate answers in any alphabet or writing system the human race has yet to create, from ancient Runes to modern Devanagari. |
![]() |
This project is intended largely as a warm-up to a later project. In both of them, you will get practice with various development tools; with a bit of Swing; with Unicode; with reading and writing invariants; and with data structures using Java collections. The amount of code you actually have to write in this project is small. The challenge is understanding how the pieces fit together. On the other hand, there are a fair amount of written questions. There is no Part A/Part B. The follow-up project will have a separate number and a somewhat different theme, but a similar structure.
Here is a snapshot of the program in operation. The upper panel is the Ouija board. When you click on it, one more character appears. That's about all there is to it.
The characters are to be generated randomly, from a range of characters. The range is specified by two characters passed to the constructor of the controlling class. These should be the first and last characters from some interesting Unicode block. You can find the hexadecimal codes for Unicode characters on the official Unicode site. To allow for non-Latin characters, Java lets you give character constants in hex. For example, Braille patterns have codes from 2800 to 28FF.
(Code links at top of page). To start with, you have two packages this time. MDUtils contains some utilities which you might not even need to look at. You won't be able to hand in any files of this package. The other package, "randchars", will contain source files for the random characters application.
The application itself is structured as three .java files. Their names are chosen to suggest the MVC (Model-View-Controller) architecture that we will be talking about in class. You have starter code for all of them. RandCharController.java shouldn't need to be modified, but it will have to be turned in. It sets up the other classes and handles the user interaction (which is simply mouse clicks). If you do modify it, don't add constructors or modify the existing constructor signature.
OuijaViewer needs modification in order to compile and run. Comments in the code should help you get there. This is where your graphics code will go.
RandCharModel is most in need of completion. The class holds the actual data of the application, that is, the list of characters generated. You will have to choose an appropriate data structure. You may not use any arrays in this class.
Write a main class and call it RandCharDriver.java. The main method can be quite short. It needs to create a RandCharController and pass it two characters. Write main so that it can be run from the command line, with two arguments (the two characters); if there are no command args, main uses two internally provided default characters. (There should be examples of this type of coding in the starter code or sample solutions of earlier projects). The program should work with any pair of characters that is supplied, but for the default characters, choose the starting and ending characters of some interesting non-English Unicode block. RandCharDriver.java should be in the randchars package.
One of the rules of the assignment (which is a general MVC design rule), is the Model must not perform viewer functions (like painting the Ouija board), and the Viewer must not contain model data. In the present circumstance, it means that the permanent list of generated characters must reside in the Model. The viewer can request a copy as a local variable, but may not keep it around. (This may seem strange and inefficient, but it has many design advantages, which we'll be discussing). The methods outlined in the starter classes are designed to lead to a simple and well-structured solution, but you are not required to adhere to them. Before adopting a different approach, however, spend sometime understanding the suggested structure.
Your results will be more interesting if you have a nice, complete Unicode font on your computer. Many Windows systems have "Arial Unicode MS", but it may be missing some of the more exotic code blocks. If you discover some good downloadable fonts, please share the information.
Some rules (for this project):
Some advice:
Please read the turn-in forms carefully when they become available, including the fine print! After submitting a form, read what comes back, too. Please make sure that you use the correct form for each part! | Turnin form |
Buona Fortuna!
Hints, Tips, and Corrections
1. RandCharDriver.java should be in the randchars package.
2. [2/10/2003]. A file named FontUtils.java has been dropped into the starter code area, within MDUtils. It has a couple of groups of methods that might help you find and manage the Unicode fonts on your system. You aren't required to use it. It will be on the turn-in server. You can't modify it to turn in.
The methods with names like setUnicodeFont might be useful in the OuijaPanel. The method will choose a font from a list of names preferred fonts and use the first one it comes to that is available. It will never fail ("never" is tempting the gods, of course...). You can also supply a font name or list of font names to be tried before any of the defaults are tried. Once you have the font, you can do a g.setFont(). Although it's too late to require you to use this method, it's strongly encouraged, because it will make our testing easier (it makes the program more portable between machines).
The methods with names like testFontsAndReport might be useful for seeing what characters can be rendered in the fonts installed on your computer. You can give it a character or a string of weird Unicode characters, and it will print out all the fonts on your system which are capable of rending those characters. Look at main to see how to use it. Modifying main might be the easiest way to experiment with it.
In experimenting, I've found that Code2000 has far and away the most weird characters -- far more than Arial Unicode MS, which seems to be second-best. Bitstream Cyberbit is pretty good, too.