c sharp hangman project (IN DESPERATE HELP)

  • Thread starter Thread starter kaylachristine
  • Start date Start date
K

kaylachristine

Guest
Hi I have a vs.net project and I need some help. Below is the project she gave us. Please use basic/low level codes



Hangman

Your challenge is to program Hangman! User should see the correct number of blanks for each letter in the word. The user is then supposed to guess one letter at a time. If it's correct, it should fill in the blank and show the correct hangman. If it is incorrect, it should add a body part (advance the hangman). It should also display the letters that have been used and print those on the screen to avoid repeats.

Task 1: Request a word to be used for the game. Store user's input to a variable. (What data type is this?) Clear screen after storing. Use: Console.Clear();

Task 2: This word will be stored to a string array. You will need to use Substring. An example of how this may be used is:

nameOfYourString.Substring (startIndex, length)

where nameOfYourString is the name of the string to be converted to a string array, startIndex is the starting index (which letter of your string) that you'd like to store - remember this starts at 0! - and length is the length of the string you'd like to use - in our case, this will be one.

Tip: If you are using a for loop, you can use .Length as the maximum for your counter, and your loop counter as your index variable for your array.

Task 3: Create a function that will request user's guess for a letter and return it as a string to Main. If the user enters in more than one letter, it should let the user know and request input again.

Tip: What kind of function is this? How can you run the error check?

Task 4: Create another string array to store the user's guessed letters, that can be used to print to the screen after each guess. The values returned from Task 3 should be stored in this array.

Tip: What kind of loop should you use for this?

Task 5: Copy the function below that includes hangmen. Notice each picture has a new body part. What does the function do and how can you implement it in your own program? Alternatively, create your own hangman function that includes the output for each hangman display.

Tip: Consider how many wrong answers will result in a loss?

Task 6: Compare the guessed answer choice with the string array for the word and replace the blanks as needed. In order to do this, you will need another(!) array, this time a bool array that will be used to indicate whether to print or not.

Task 7: Make sure your program will tell the user if they win or lose. Make sure you have accounted for user errors like:


  • typing in more than one letter for the guess,

  • capital vs. lowercase letters (you can use nameOfString.ToLower)

  • user types in something other than letters

  • user types in same letter more than once

Once complete, make sure you have commented your code (probably helpful to do as you go along) and run it multiple times to check for errors (this means more than once!).




static string[] HangDudes()

{

string[] dudes = { @"

+---+

| |

|

|

|

|

=========", @"

+---+

| |

O |

|

|

|

=========", @"

+---+

| |

O |

| |

|

|

=========", @"

+---+

| |

O |

/| |

|

|

=========", @"

+---+

| |

O |

/|\ |

|

|

=========", @"

+---+

| |

O |

/|\ |

/ |

|

=========", @"

+---+

| |

O |

/|\ |

/ \ |

|

=========" };

return dudes;

}

Continue reading...
 
Back
Top