The Hangman Game

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

The Hangman Game

The purpose of this assignment is to be able to apply the following programming


concepts towards the creation of a well-structured program, which produces the correct
results: strings and using the C String library, arrays of strings, loops, decision
statements, expressions, variables and console i/o.

Extend/rewrite/correct the program from your previous lab assignment to include the
following new functionality. Everything else stays the same as in the previous lab.

New functionality:
1. Randomly choose a secret word from 10 words you have available and stored
in a 2D array of strings. Assume these words can be as big as you wish.
2. The player can enter either a character OR a string as his/her guess in any try.
If the string matches the secret word, the player is awarded the points for
finding the word with a guess according to the points below, otherwise points
are deducted as below. See the 2 new criteria in the table below.

Examples:
So, for example, if the secret word is mystery and the player guesses the word with the
first try, he will earn 200pts for finding the word using a “word guess” plus 100pts for
finding the word overall for a total of 300 pts. If the player enters windows as his first
guess, then he loses 80pts, his first try, but he is able to continue to find the word as he
has 9 more tries. If he does not find the word in his remaining tries, 40 more points are
deducted because he did not find the word overall.

Criteria Points

Letter found 10

Letter not found -2

Word found 100

Word not found -40


Word entered as 200
guess and found

Word entered as -80


guess but not
found

3. Implement menu item 2. “Display Statistics”. Keep statistics on all players who
have played the game and display these statistics in descending order from
highest score to lowest score, i.e. player name and score, in a nicely formatted
manner, once this menu option is chosen. Assume 50 players max. We have
not learned about files yet, so you should assume that we are referring to
players who played the game during the current execution (run) of the
program.
4. During the game, display the letters that have been incorrectly guessed so far
(sorted alphabetically).
5. During the game, display the letters the player can still choose from (sorted
alphabetically). These are all the letters except those guessed by the player
already.

You will need to demonstrate strings and using the C String library, arrays of strings,
arrays, loops, if-else and switch/case statements and use of functions (and passing arrays
to functions) in this program. No global variables are allowed! You can use the following
naming convention (or anything you choose, but you need to stick to it!): camel casing
for variable names, Pascal casing for functions and all capital for constants. Do not forget
to comment your code where necessary. The minimum is a function header for each
function and a program header to explain what your program does. All code should be
written in a single .c file. Test your program to make sure it works properly. Assume no
error checking for invalid data. You should handle the case where the user enters
anything different than 1, 2 or 3, in the menu though.

You might also like