@@ -16,7 +16,7 @@ public class Quiz {
16
16
17
17
private int score ;
18
18
19
- private static final Random rand = new Random ();
19
+ private static final Random rand = new Random (); // used for calculating random numbers
20
20
21
21
/**
22
22
* Precondition: flashcards contains at least 4 flashcards, and at least 1 question type is enabled in quizSettings.
@@ -37,7 +37,7 @@ public Quiz(QuizSettings quizSettings, List<Flashcard> flashcards) {
37
37
public void generateQuestions () {
38
38
int numQuestions = this .quizSettings .getNumQuestions ();
39
39
40
- ArrayList <String > types = new ArrayList <String >();
40
+ List <String > types = new ArrayList <>();
41
41
if (this .quizSettings .isTrueFalseOn ()) {
42
42
types .add ("TF" );
43
43
}
@@ -72,39 +72,50 @@ public void evaluate() {
72
72
}
73
73
}
74
74
75
- /** GETTERS AND SETTERS **/
76
- public ArrayList <String > getUserAnswers () {
77
- ArrayList <String > userAnswers = new ArrayList <>();
78
- for (QuizQuestion q : this .quizQuestions ) {
79
- userAnswers .add (q .getUserAnswer ());
80
- }
81
- return userAnswers ;
82
- }
83
-
84
- public void setUserAnswers (ArrayList <String > userAnswers ) {
75
+ /**
76
+ * Sets the user answers.
77
+ * @param userAnswers the user answers
78
+ */
79
+ public void setUserAnswers (List <String > userAnswers ) {
85
80
for (int i = 0 ; i < userAnswers .size (); i ++) {
86
81
QuizQuestion q = this .quizQuestions .get (i );
87
82
String a = userAnswers .get (i );
88
83
q .setUserAnswer (a );
89
84
}
90
85
}
91
86
92
- public ArrayList <String > getActualAnswers () {
93
- ArrayList <String > actualAnswers = new ArrayList <>();
87
+ /**
88
+ * Gets the actual answers.
89
+ * @return the actual answers
90
+ */
91
+ public List <String > getActualAnswers () {
92
+ List <String > actualAnswers = new ArrayList <>();
94
93
for (QuizQuestion q : this .quizQuestions ) {
95
94
actualAnswers .add (q .getActualAnswer ());
96
95
}
97
96
return actualAnswers ;
98
97
}
99
98
99
+ /**
100
+ * Gets the quiz questions.
101
+ * @return the quiz questions
102
+ */
100
103
public List <QuizQuestion > getQuizQuestions () {
101
104
return this .quizQuestions ;
102
105
}
103
106
107
+ /**
108
+ * Gets the quiz score.
109
+ * @return the score
110
+ */
104
111
public int getScore () {
105
112
return this .score ;
106
113
}
107
114
115
+ /**
116
+ * Gets the number of questions.
117
+ * @return the number of questions
118
+ */
108
119
public int getNumQuestions () {
109
120
return this .quizQuestions .size ();
110
121
}
0 commit comments