wood burning stoves 2.0*
The moose likes Java in General and the fly likes need help in word guessing game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "need help in word guessing game" Watch "need help in word guessing game" New topic
Author

need help in word guessing game

Clara Johnson
Greenhorn

Joined: Dec 05, 2012
Posts: 10
this is a simple word guessing game that i have made, how many words can you make from the word "netbeans"
i want to store the words guessed by the user in an array that keeps on adding the words the user guesses...please help someone
this is my coding


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150

Clara,
You don't say what you are stuck on.

One general tip: you want to use an ArrayList, not an array. With an ArrayList, you don't need to know the size in advance.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Clara Johnson
Greenhorn

Joined: Dec 05, 2012
Posts: 10
thanks for the help, well i am stuck on how to do this with array list?? could you please give me some example...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150

First you need to instantiate the ArrayList. This would be a local variable, like result. Then you need to add Strings to it. Where do you think you could do that in your code?
Clara Johnson
Greenhorn

Joined: Dec 05, 2012
Posts: 10
should i do it in here?? inside the if-else condition...or what would you suggest?

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150

No, I wouldn't do it inside the if statement (or the loop for that matter. You only want to add the word once per guess.

Which means my advice about where to create the ArrayList wasn't valid either. It needs to be created outside the check() method so you can store state across method calls to check().
Clara Johnson
Greenhorn

Joined: Dec 05, 2012
Posts: 10
is it ok?? what to do now??

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help in word guessing game
 
Similar Threads
Return number of characters in a Word
javafax, button action..NEED HELP PLEASE!!!
Head First Java: Guessing Game infinite look
Need help ending number guessing game and asking if user wants to play again
Illegal Access Exception