I'm creating a simple quiz game. In this game, the question and the respective answers will be randomly generated. I created a list "q" to the questions.
And for the answers, I created various lists with 4 strings each one. For example, if the question is the 0 in the q list, the answers for this questions will be in the list "a0", right? But I'm having some problem to get the strings in the list of answers. I've tried this:
while(true){
Integer nxt = rng.nextInt(6);
if (!generated.contains(nxt))
{
generated.add(nxt);
textView1.setText(((ArrayList<String>) q).get(nxt));
String x;
x = ("a" +nxt);
Collections.shuffle((x));
btn1.setText(((ArrayList<String>) x).get(0));
btn2.setText(((ArrayList<String>) x).get(1));
btn3.setText(((ArrayList<String>) x).get(2));
btn4.setText(((ArrayList<String>) x).get(3));
break;
}
}
I created a string "x" to get the right list. If the "nxt" is 4, the buttons texts will get the strings in the list a4.
But in my code, the "Collections.shuffle" and the "setText" try to find the list "x". It's not going in the way I imagined.
How can I fix it?
*My idea is check the string of the button clicked and compare with another list of RIGHT answers. In that way, I can attributte the right answer and the other 3 wrong.