Hangman in BlueJ (Java)

December 9, 2005 at 11:03:47
Specs: Windows XP Pro, AMD 64 3700+ / 1Gb pc3200

Hi,
i'm makingHangman in BlueJ (using TextIO)...as i have the word to be guessed replaced by '*' could anyone give me a template for a 'For Loop' or 'If statment' which ever is more relevant which i can work with cos i need to find the instance of each letter guessed in the word and i haven't a clue where to start.
Thanks in advance

Theres only 10 people that understand binary, those who do and those who don't.


See More: Hangman in BlueJ (Java)

Report •


#1
December 12, 2005 at 21:25:53

Well, you'd have the word in an array, say word[]. Then your guessed letter would be a char guess. Also, you'd have a temp array that is all *s. You'd do something like this.


for(i=0;i<word.length;i++)
{
if(word[i].equals(guess))
{
temp[i] = guess;
}
}
for(i=0;i<temp.length;i++)
System.out.print(temp[i]);


That's the hard part of the whole program. BTW, that's just off the top of my head, I have an old hangman program I made once. If you want I can try to dig it up and send it to you.

Alert me after you respond otherwise I'll forget to come back.


Report •

#2
December 12, 2005 at 21:27:11

So much for formatting. Well, you get the idea.

Alert me after you respond otherwise I'll forget to come back.


Report •

#3
December 13, 2005 at 03:05:38

yes that would be great....my address is japanesebuzzsaw@hotmail.com Thanks v much.

Theres only 10 people that understand binary, those who do and those who don't.


Report •

Related Solutions


Ask Question