In order to complete this applet, we can split it into the following parts:
First, get a copy of a real Dictionary class. Copy the file Dictionary.java from there into your Hangman project Folder. Add this file to your project. Take a look at the file and make sure that the required interface (i.e. use of Dictionary class, and getWord()) is the same as in your version. Run your applet using this new Dictionary file and ensure that you are able to successfully use this version.
Next, you just have to finish up whatever remains to be done. So far, you probably have an applet that selects a word, and allows the user to guess the word in a given number of attempts (dictated by the number of steps needed to complete the Hangman).
First, make sure that you do the enabling and disabling of buttons as the user guesses letters. Any button can be disabled or enabled using the commands:
b.disable(); // where b is any button b[i].disable(); // where b[i] is the ith button b.enable(); b[i].enable();
You should disable the button in actionPerformed (as soon as you know that it was pressed. Disabling buttons is helpful to the user as it indicates which letters have already been tried. If you do not disable buttons, you will have to add some other way of indicating this information to the user. All buttons should be enabled every time a new word is selected. Similarly, you may also want to disable the New Word button when the user is trying to guess the word. If the user guesses the word or runs out of tries, this button should be enabled again.
If you'd like, add a variable(s) to keep track of average number of guesses/word. You can display this information in some part of the applet as well.
Complete the project by Wednesday, December 10. Remember to schedule a time with your Professor to show the applet. For this project, all you will need to hand-in, in printed form, is an essay on your experiences with the project. The project itself will be graded at the time of demonstration. Sign-up sheets will be posted outside the Professor's doors. Make sure you sign up, remember the appointment, and show up ON TIME. |