오픈되어있는 소스고
퀴즈가 현재 1번부터 10번까지 실행되고 반복되어 실행되는데
1번부터 20번까지 실행하고 싶은데 잘 안되서 고쳐야하는 부분이 있는지 한번만 봐주세요
public QuizDriver() {
super();
questionBank = new ArrayList<QuizQuestion>();
questionList = new ArrayList<QuizQuestion>();
answers = new boolean[10];
questionsAttempted = new boolean[10];
for(int i=0; i<answers.length-1; i++) {
answers[i] = false;
}
//selectQuestions();
}
public void selectQuestions() {
questionList.clear(); // just in case
Random rng = new Random();
ArrayList<Integer> generated = new ArrayList<Integer>(); // keep track of the selected question number..no duplicates
for (int i = 0; i < 10; i++) { // need 10 questions
while(true) {
Integer next = rng.nextInt(50); // 0 - 49
if (!generated.contains(next)) {
questionList.add(questionBank.get(next)); // add the selected question to questionList from questionBank
generated.add(next); // save the selected number to check for dups
break;
}
}
}
}