Les Morgan wrote:Here is a very basic layout. You can put a button on the bottom and more on to the next question, and use the setText method in the JRadioButton and JLabel to change the text for the next QA round.
Carey Brown wrote:In OO you would create a Question class. Your main class would contain a List<Question>. The Question class would contain a List<String> for the answers and an int of which answer is correct You main class would shuffle the Question list ... Collections.shuffle( questionList ) ... (if I remember correctly).
You could add another layer of abstraction by having an Answer class. An Answer class would have a String for the question and a boolean to flag the correct answer. In this way you could also shuffle the answers.
Liutauras Vilda wrote:Initially I was thinking about to suggest you to ease your life with HashMap instead of parallel arrays, but Campbell Ritchie is right, that would be a changing of one bad way doing this with another bad way.
So you most likely need to consider of moving to Objectville. Have you learned about writting classes yet?
I can't remember in which book I've seen such problem, I think it was in one of: either "Head First Java" or Cay Hortsmann "Java for Everyone, Late Objects". If I'm not mistaken, there are good suggestions and hints how to implement it in object oriented way.
If you're thinking to move along with this app further, you could try to look up for those books in your local library.
Campbell Ritchie wrote:The answer is really simple: get some objects and beat them into submission. Create a Question class which encapsulates both question and answer. When you sort/search/randomise the questions, all the answers will follow.
Liutauras Vilda wrote:Welcome to the Ranch.
Difficult to determine if you chose right approach in general, for solving that problem.
Could you please specify how that test question sounds?
[edit] I am sorry, I misread your post. I thought you're solving test, it appears you're creating one.
Still, question remains similarly, do you have whole idea what your program is supposed to be doing? Could you please explain a bit more about it.
Les Morgan wrote:
Jeanne Boyarsky wrote:The removeFirst() method returns the start value in addition to removing it. For example:
Note that it is Java convention to have classnames begin with a capital letter along with subsequent "words" rather than using underscores. Making your class name KristersDrozds3.