Results 1 to 1 of 1
Thread: hang man problem
- 03-05-2013, 08:20 PM #1
Member
- Join Date
- Mar 2013
- Posts
- 1
- Rep Power
- 0
hang man problem
Sorry, I just got it to work.. Thanks anyways..
Hello, i'm currently working on this hangman project and I cant seem to get it to work. basiacally the main thing that its doing is its only testing the last charactor in the string that its using as the hidden word ive worked for a few days on this and i cant seem to fix it.. can any one see what im doing wrong here?
Thanks in advance!Java Code:public class hangMan { public static void main(String[] args) { boolean stillPlaying = true; String word = "hat"; String wordAsBlanks[] = new String [word.length()]; CinReader reader = new CinReader(); do{ for(int i=0;i<word.length();i++) { System.out.print(wordAsBlanks[i] = " - "); }//end for System.out.println("Guess::"); String userGuess = reader.readString(); for(int j = 0;j<word.length();j++) { if(userGuess.equals(word.substring(j))) { System.out.println("Correct"); wordAsBlanks[j] = userGuess; break; } }//end for }//end do while(stillPlaying); }//end main }
Sorry, I forgot to get rid of that for loop using k as an increasment operator around System.out.println("Guess::"); I just removed it.Last edited by maddogg2222; 03-05-2013 at 10:44 PM. Reason: solved
Similar Threads
-
code gets hang
By rungtashubham in forum AWT / SwingReplies: 4Last Post: 03-22-2012, 07:40 PM -
What type of hang? and how to fix?
By joshbrigade in forum New To JavaReplies: 2Last Post: 11-06-2009, 10:40 PM -
Read XML from Internet Hang!
By yupingliew in forum NetworkingReplies: 0Last Post: 10-22-2009, 05:56 AM -
Applet hang
By Worlock in forum New To JavaReplies: 2Last Post: 08-10-2009, 06:43 AM -
Web application hang without comm.jar
By chankokchern in forum Java AppletsReplies: 0Last Post: 12-16-2008, 12:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks