I'm trying to make a GUI for a quiz program with several questions displayed at the same time with 3 answers each. The anwsers are displayed in radiobuttons. I have to test each radio button 3 times(if selected/good/bad anwser, none selected). Each radiobuttons name are like this:KxValaszy. Where x represents the number of the question, and the y represents the number of the answer. So the first questions first anwers's radiobutton name is:"K1Valasz1", and so on. My problem is that testing each radiobutton 3 times is quite a lot of typing, is there any way to dinamically create the names of these radiobuttons? Like something like this?
for (int i = 1; i <= 10; i++) {
for (int k = 1; k <=3; k++) {
answer = ("K" + i + "Valasz" + k);
if (KvizValaszok.answer.getText().equlas("OneGooDAnswer");
NumberOfGoodAnswers++;
}
}
This is an altered portion of the code and obviosly not working is just wanted to furter demonstrate exactly what do I want to do. Sorry for my English, and my Java skills I just started coding in Java :)