Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2010, 08:46 PM   PM User | #1
Gertruid
New to the CF scene

 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Gertruid is an unknown quantity at this point
Question Need help coding a simple Hangman game

Hello everybody!

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?
Gertruid is offline   Reply With Quote
Old 01-11-2010, 10:29 PM   PM User | #2
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
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.
brad211987 is offline   Reply With Quote
Reply

Bookmarks

Tags
game, replace, simple

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:23 PM.


Advertisement
Log in to turn off these ads.