View Full Version : Java Question
11-26-2003, 12:00 PM
I have an assignment for class, I have to create the game Hangman. It has to run in the command prompt. I have drawn scafold and created an array with words. I can randomly generate a word from that list. My first problem comes in getting the length of that word. I can't seem to figure out how to get the length of the word. When I get the length of the word i can loop the length to draw __'s for the length. My next problem would be, how do you get user inputs as guesses from the command prompt as guesses, then determine if they are in the actual word generated, then return a wrong if wrong, display correct letters in place, and add the list of guessed letters to the settings. As you can see I am pretty much a n00b so any help would be great.
11-26-2003, 03:35 PM
Would this help?
String word = "guess";
int lengthWord = word.length();
String guess = "guess";
11-26-2003, 07:00 PM
you need to review the functions. Oakendin is correct with the word.length() function it will return an int and give you the length of the word. You now need to find a function similar to ElementOf so that you can see if the guess is contained in the word. Look into that...
11-27-2003, 12:16 AM
Thanks, I know have the length of the word and can display the correct ammount of spaced for the word. Now I am completely lost on how to get guesses and check
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.