Hangman Game

Click to view the code

This is a final project for my Intro to Programming and Logic class at South Hill. I used C# to create a hangman game in a Windows Form Application.

The form loads and a random word is selected from a list. The initial display shows a welcome greeting, the hang post, dashes for each letter of the random word, a label for showing the missed letters, a label showing the word length, a label showing how many guesses are left, a submit letter button with a corresponding text box, and a submit word button with a corresponding text box.15

The user types in a capital or lowercase letter in the submit letter text box

2

If the user tries to enter anything other than a letter, an error message will be displayed.

3

If the user tries to enter the same letter more than once, an error message will be displayed.VirtualBox_Dark Side_07_12_2015_16_03_50

If the user guesses a correct letter, the corresponding dash changes to that letter. Nothing else changes on the form and the user can select another letter to submit.

4

If the user guesses wrong, a message box will pop up and let them know.

5

After the user clicks ok on the message box, the missed letter label will display the wrong letter they guessed, the guesses left will decrease by one, and a new body part will be drawn on the hang post. The following screenshots will show the order of the body parts being shown until the user loses.

6

7

2eyes

smile

8

9

10

11

When the user has guessed wrong for the last time, the last leg will be displayed and a message box will pop up telling the user that they lost along with what the random word was.

12

If the user knows the word they can also enter it in the submit word text box if they do not want to continue guessing every letter. If they guess wrong the same pop up message will be displayed as when they guess a letter wrong, a new body part will be drawn, and the guesses left will decrease by one.

13

If the user either guesses all of the letters correctly or guesses the word, a pop up displaying a winning message will be displayed.

14

After the user wins or loses and presses ok on the pop up box, the form will automatically reset and select a new random word so the user can play again.

1