The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Game for Small Children Program

Hello everyone. I've been told to post my questions here. I'm a novice programmer who needs to write a game program for small children that shows images of animals whose names are only three letters in length(e.g. "cat" "dog"). It has three panels for the letters to be placed and a keyboard of buttons for the child to choose from that places the chosen letter in one of the three panels. It still needs a play button, code that congratulates the child for getting the correct animal and vice versa, and it needs a "Play Again?" button. It supposed to use arrays, loops, and whatever else there is to use as a novice programmer. Here is a link to my code. Pastebin.com

I'm using NetBeans if that makes a difference, the problem I'm having with my code is that I still need it to put in letters into the other two panels and recognize whether or not they are the correct letters. As a student I would like an explanation for any changes made, I'm here to help me learn how to write Java code, because my teacher is difficult to understand and doesn't always explain things very well.

All help is appreciated and I thank you all in advance for even looking over my code. Below is a "too long; didn't read" version of my post.

TL;DR
Want to learn how to write code for the given school assignment, many thanks to those who help.

Re: Game for Small Children Program

Hello Javazoid,

Your ButtonHandler classes actionPerformed method always sets the text of box1Tf and never box2Tf/box3Tf. To do this you will need to create a logic statement checking to see if the boxes have text already or not and move on accordingly. That can be accomplished through some simple if statements. So if box1 has text then write to box2 or if box2 then write box3 etc... Of course that is only one way to go about it. To see if the answer is correct you will need to concatenate the contents of the three boxes and check it against an answer string. Hope that can help a bit.

Re: Game for Small Children Program

Okay, I've gotten a little further on the code and it now can display the three correct letters in the boxes. I didn't understand what you meant by "some simple if statement" not really sure which one. Assume I don't know anything about Java and explain it very basically, or give examples of code snippets I could apply. I still need the program to reset itself after the correct answer is received, and display an error when the wrong answer is received.