I've done this before years ago. Mine wasn't limited to 4 letter words though. I will not write any program for you or give you mine, but I will explain as best as I can what you need to do (from my recollection). I'm also assuming that you are given the GUI.
When you get the word that is to be the "secret word", store it into an array. I would also suggest that you turn each letter into lower case. Make a second array and fill it with 4 underscores. This array is what will be displayed on the GUI. Now, when the user types in a letter, compare it to each letter of the secret word array. It'll be easy since you only have 4 letters. You could just pound it out instead of using a while or for loop. If there's a match, just put that letter in the correct location of the underscore array.
I don't remember anything about keeping track of letters already used, but my guess would be to set up another array that places the letters they type into it. Then just compare the next letter they type to the elements of that array. This one you'll probably need to use while/for loop.
Also, on second thought, I didn't do this for java. It was another programming class that I have no recollection of. But, this will work. And, your program so far looks pretty empty.
__________________
SIGNATURE.
|