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.

Final Project - Trivia Game

I'm currently in a pre-ap java programming exposure class. For our final project, we must make some sort of working program like a video game of sorts. It can't be a simple slide show type game. The problem is, ladies and gentlemen witnessing my plea, that the "pre-ap" factor of this class has caused me problems. I don't have trouble maintaining a good grade in the class. But it's to the point that these last few months have been us being rushed through chapter questions to the point where you have to use control-F to find answers to get done in time opposed to actually reading the material and learning. Which leads me to believe I'm in need of lots of grace.

The program itself, what I thought would be simplest, is to make a trivia game with four categories, each of the categories having 1-2 questions. I also wanted to include the 'back' and 'next' buttons. This is as far as I've gotten as to ideas. The true problem is actually coding it. In all honesty, I understand simple concepts, but the entire class we've never had to start from scratch, and all the coding for more complicated parts of the program was already given to us, so when it comes to what to actually write from scratch, I've got nothing.

Be aware that if you post on this offering help, I will be asking several questions and you may be here awhile. Thanks!

Re: Final Project - Trivia Game

First off- break your problem down into much smaller steps. Break those small steps up into even smaller steps. Keep them separated until you have them working perfectly, then worry about combining them.

Write out what you want to happen, as specifically as possible. Pretend you have a really dumb friend, and write directions for him to follow.

Concentrate on the simplest thing you know you have to do, and go from there. When you get stuck, break the problem down into an SSCCE and ask a specific question, and we can help you from there.

This might sound like more work, but I promise, it will save you a ton of headaches along the way.

Re: Final Project - Trivia Game

We've started and made progress. Not near as bad as I thought it would be. We went with the idea of having a program that displayed all the 50 states with their own individual button, and when you clicked on the button, it took you to a slide of that state's bird and gave information on it. Rather simple, but what I'm wondering is: Do I have to make a method for each individual state? Because each state is going to have to have their own individual slide for when you click on their button. Also, we're intending to add a 'back' button. I know to use an if statement for whenever they click in a certain area to perform a certain task. But I don't know how to get the back button to redirect them to the original slide at the beginning.(Which is the one with all 50 states' buttons on them.)

Re: Final Project - Trivia Game

Another thing I just realized that I didn't mention was that we also intend on adding the 'next' button. The same thing I'm confused about the 'back' button with applies here. I know how to use the if statement for when the user is clicking in a certain area, but I don't know exactly what to tell it to do. I'm going to have to tell it to go to the next slide.(because we have 25 states on the first slide, 25 on the next) But I don't know the coding to do so.

Re: Final Project - Trivia Game

This kind of thing is usually done with a combo box - a dropdown list of items (e.g. names of states) from which you can select an item. Use an array of buttons if that's what you really want, but it sounds a bit clunky to me... When an item is selected, its name or index number is used to select the image to be displayed. To do this selection, you could use a method that takes the name of the state and reads an image file with that name from an image folder on the disk. Alternatively, you might have read all the images into your program at the start, so you might have a map that holds the images keyed by state name. You could then use the name to retrieve the image from the map.

An important concept in coding is to avoid duplicating code. If you have to do the same operation with many different items of data, use the same code each time (e.g. a method, or a loop) and pass the data items to it (e.g. as method parameters).