diff --git a/app/src/main/java/com/noprestige/kanaquiz/KanaQuestionBank.java b/app/src/main/java/com/noprestige/kanaquiz/KanaQuestionBank.java index 651c24db..077c0cf6 100644 --- a/app/src/main/java/com/noprestige/kanaquiz/KanaQuestionBank.java +++ b/app/src/main/java/com/noprestige/kanaquiz/KanaQuestionBank.java @@ -8,6 +8,7 @@ class KanaQuestionBank extends ArrayList { private KanaQuestion currentQuestion; + private ArrayList fullAnswerList = null; private Random rng = new Random(); private static final int MAX_MULTIPLE_CHOICE_ANSWERS = 6; @@ -51,12 +52,14 @@ String fetchCorrectAnswer() boolean addQuestions(KanaQuestion[] questions) { previousQuestions = null; + fullAnswerList = null; return super.addAll(Arrays.asList(questions)); } boolean addQuestions(KanaQuestion[] questions1, KanaQuestion[] questions2) { previousQuestions = null; + fullAnswerList = null; return (super.addAll(Arrays.asList(questions1)) && super.addAll(Arrays.asList(questions2))); } @@ -64,6 +67,7 @@ boolean addQuestions(KanaQuestion[] questions1, KanaQuestion[] questions2) boolean addQuestions(KanaQuestionBank questions) { previousQuestions = null; + fullAnswerList = null; return super.addAll(questions); } @@ -74,11 +78,13 @@ String[] getPossibleAnswers() String[] getPossibleAnswers(int maxChoices) { - ArrayList fullAnswerList = new ArrayList<>(); - - for (int i = 0; i < size(); i++) - if (!fullAnswerList.contains(get(i).fetchCorrectAnswer())) - fullAnswerList.add(get(i).fetchCorrectAnswer()); + if (fullAnswerList == null) + { + fullAnswerList = new ArrayList<>(); + for (int i = 0; i < size(); i++) + if (!fullAnswerList.contains(get(i).fetchCorrectAnswer())) + fullAnswerList.add(get(i).fetchCorrectAnswer()); + } ArrayList possibleAnswerStrings = new ArrayList<>();