CS 0447 – Project 1: Hangman

Due: Tuesday, June 25, 2013 by 11:59pm

Description

Your first project is to implement the game of Hangman. In this game, the computer chooses a random word or phrase.  The player’s job is then to guess the word or phrase that the computer has chosen. Each turn is a guess by the player of a single letter. The computer will display where that letter is in the proper position. If the letter is not in the word or phrase, or has been already guessed, the player loses part of their “life”. The player wins when they guess the exact word or phrase the computer chose. The player must not guess more than 6 incorrect letters, otherwise the player loses.

What you need to do:

·         Choose a random word or phrase from a list of 10 such words declared in the .data section.

·         Output the letters as blanks (underscores separated by spaces).

·         Read a guess from the user as a string or character (see example below). Assume the input is lowercase.

·         Convert each letter to uppercase in the output (see example below).

·         For each letter that is correct, show its proper position in the output.

·         Allow the user to continue to guess letters until they get it correct, or reach 6 wrong answers and they lose.

·         Allow the user to play the game multiple times.

Example:

Welcome to Hangman!

 

The word to guess is: _ _ _ _ _

 

Enter guess number 1: c

 

The word to guess is: C _ _ _ _

 

Enter guess number 2: z

---.

|  O

|

 

ASCII Art

We will draw the hangman (representing how many incorrect letters have been guessed) in 6 parts:

---.

|  O

|

| 

---.

|  O

|  |

| 

---.

|  O

| /|

| 

---.

|  O

| /|\

| 

---.

|  O

| /|\

|    /

---.

|  O

| /|\

|    /  \

Head

Torso

Arm

Arm

Leg

Leg

First miss

Second miss

Third Miss

Fourth Miss

Fifth Miss

Last Miss, game over

Hints:

Submission

Create a zip file of your source code and a README.txt text file that has your name, your Pitt username and any notes for the TA to help with grading.

Name the file USERNAME-project1.zip

Use the lab submission policies to upload your project.