Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-11-2010, 08:46 PM #1
- Join Date
- Jan 2010
- Thanked 0 Times in 0 Posts
Need help coding a simple Hangman game
For a class project, I am creating a simple version of Hangman.
The phrase the user has to figure out will be "My teacher is the best."
When it starts out, it will print "-- ------- -- --- ----." Please enter a letter.
I am having some trouble, however, with the script being able to read the letter I enter and replace it with the corresponding hyphen.
So when you type in "e", the script prints out "-- -e---e- -- --e -e--."
And then they enter a "t", it will print out "-- te---e- -- t-e -e-t."
Until each letter is guessed
How do you do that?
01-11-2010, 10:29 PM #2
You will have to be much more specific to get anywhere with your question.
Have you started the program?
What have you tried?
What part is giving you trouble?
I would start with a String that contains the actual key, and use the standard methods supported by the String class to read where and at what index each character resides.
Alternatively, you could use a character array and access the string as a standard array, but I would go with using a String.