Hangman is a traditional children's game, typically played with words. It's possible, however, to play Category Hangman --- rather than guessing words the player might guess names of cities, or athletes, or fictional characters, or Duke professors or top forty song titles --- the list is endless.
You'll be writing a program to play a "guess a word letter-by-letter" version of hangman as shown below. You'll also be doing some statistical analysis of the words used in the Hangman game.
This assigment is very similar to the hangman assignment in CompSci 6, but with the addition of an analytical part.
You're given a class HangmanFileLoader.java which you use in the game to get a word the user will guess. See the howto for details. For this first part of the assignment you'll add to code started for you in HangmanStats.java to answer one question we ask and to ask and answer another question you decide on.
We want you to estimate the number of different words
there are of 4, 5, 6, and so on up to 20 letters long. You can do this
by repeatedly calling HangmanFileLoader.getRandomWord(6), for
example, and adding the
returned word to a set. The size of the set is an estimate
of the number of words of length 6. See the howto
for more details.
HangmanFileLoader. You should also write code to answer your
question and include the data in the analytical writeup you turn
in. You could, for example, wonder how many calls are needed before
some word is returned that was previously returned . You could write
code to determine this. Any question you write is fine, but you must
write code to answer the question. You're welcome to come up with
'extra' questions (up to three) that you don't write code for, but
which you'd like to be able to answer/write code to answer. Include
all questions in your analytic writeup.
One detail you should consider is duplicate letters. If you have already guessed 'e' and then you guess 'e' again, that should not cost you a guess.
Details and guidelines of how to organize the program, including the methods you should write, are describd in the howto pages.
In the run below the user input is in italics, the other text is printed by the program.
# letters in word: 8 # guesses to hanging: 7 _ _ _ _ _ _ _ _ misses left: 7 guesses so far: guess letter: e no e _ _ _ _ _ _ _ _ misses left: 6 guesses so far: e guess letter: a no a _ _ _ _ _ _ _ _ misses left: 5 guesses so far: a e guess letter: o no o _ _ _ _ _ _ _ _ misses left: 4 guesses so far: a e o guess letter: u no u _ _ _ _ _ _ _ _ misses left: 3 guesses so far: a u e o guess letter: i _ _ _ i _ _ i _ misses left: 3 guesses so far: a u e o guess letter: s no s _ _ _ i _ _ i _ misses left: 2 guesses so far: a e o s u guess letter: t no t _ _ _ i _ _ i _ misses left: 1 guesses so far: a e o s u t guess letter: r _ _ r i _ _ i _ misses left: 1 guesses so far: a e o s u t guess letter: n no n you are hung :-(, secret word is cyrillic
Submit using the submit name hangman.