Compsci 101, Fall 2014, Hangman

See the howto pages for details on starting this project, code, and so on. The pages here describe in broad strokes what this assignment is about.

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, names of US Presidents or top forty song titles --- the list is endless. To play online try hangman.no for some fun.

You'll be writing a program to play a "guess a word letter-by-letter" version of hangman as shown below and decribed in detail in the howto pages.

According to this article the hardest words to guess in hangman are jazz, buzz, and jazzed if you lose with 8 misses though with 11 misses allowed jazzed is apparently harder to guess than buzz.

Overview

Write a program to play a console-based, word-oriented game of hangman. For extra credit the user should be able to choose a theme other than words, e.g., Duke Professors, Football teams, Movies, and so on.

For the standard word-oriented hangman the user should be allowed to specify the number of letters in the word and the number of misses until the game is lost (see the sample runs below for details). The program should be reasonably robust in the face of faulty input from the user, though don't go overboard in writing code to protect against bad input.

Details and guidelines of how to organize the program, including the methods you should write, are describd in the howto pages. It's important to adhere to these guidelines.

Sample Run

Here's a sample run of Hangman. You do not need to follow the format exactly, but you should include with each turn the player takes the following information:

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

Your Task

Snarf the demo files for assignment5. You can also see the files here:

Extra Credit

Words are kind of old, offer the user the choice of playing hangman in more than one category, reading lines from files you provide, e.g., instead of words use actors, books, and so on. Files of data must be line-oriented, e.g., each "word" (or song title or famous person) is on one line, with parts of the "word" separated by spaces. Create at least three different files, each file with at least 20 entries. Your program when run would load all the files in and then ask the user which category (words, movie titles, superheros, book titles) for example, and then plan hangman with that category. Alternatively, your program might just load the file it needs after the user selects the category.

What to Submit

Please submit the following:

Submit the items to the folder assign5-hangman using eclipse/ambient or the websubmit.

Your grade will be based on how well your program functions.