Skip to content

Commit 85805cd

Browse files
timer is implemented. i need to work on documentation now
1 parent e41f67c commit 85805cd

File tree

7 files changed

+174
-84
lines changed

7 files changed

+174
-84
lines changed

src/main/java/entities/MultipleChoiceQuestion.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@
1010
* @author Anthony
1111
*/
1212
public class MultipleChoiceQuestion extends QuizQuestion {
13+
/* If given term is true, then the term is the initial prompt.
14+
If given term is false, then the definition is the initial prompt.
15+
*/
1316
private final boolean givenTerm;
1417

1518
private String question;
16-
private String[] choices;
19+
private final String[] choices;
1720
private final int numChoices = 4;
1821

1922
private static final Random rand = new Random();
2023

24+
/**
25+
* Constructs a multiple choice question.
26+
* @param flashcards the list of flashcards
27+
* @param index the index of a specific flashcard
28+
*/
2129
public MultipleChoiceQuestion(List<Flashcard> flashcards, int index) {
2230
this.givenTerm = rand.nextBoolean();
2331
this.choices = new String[numChoices];
@@ -54,6 +62,10 @@ public void generateQuestion(List<Flashcard> flashcards, int index) {
5462
}
5563
}
5664

65+
/**
66+
* Returns the string representation of the multiple choice question.
67+
* @return string representation
68+
*/
5769
@Override
5870
public String toString() {
5971
StringBuilder s = new StringBuilder("Prompt: " + this.question + "\n");
@@ -63,15 +75,26 @@ public String toString() {
6375
return s.toString();
6476
}
6577

66-
/** GETTERS AND SETTERS **/
78+
/**
79+
* Gets the question.
80+
* @return the question
81+
*/
6782
public String getQuestion() {
6883
return question;
6984
}
7085

86+
/**
87+
* Sets the question.
88+
* @param question the question
89+
*/
7190
public void setQuestion(String question) {
7291
this.question = question;
7392
}
7493

94+
/**
95+
* Sets the choices.
96+
* @return the choices
97+
*/
7598
public String[] getChoices() {
7699
return choices;
77100
}

src/main/java/entities/Quiz.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Quiz {
1616

1717
private int score;
1818

19-
private static final Random rand = new Random();
19+
private static final Random rand = new Random(); // used for calculating random numbers
2020

2121
/**
2222
* Precondition: flashcards contains at least 4 flashcards, and at least 1 question type is enabled in quizSettings.
@@ -72,7 +72,10 @@ public void evaluate() {
7272
}
7373
}
7474

75-
/** GETTERS AND SETTERS **/
75+
/**
76+
* Sets the user answers.
77+
* @param userAnswers the user answers
78+
*/
7679
public void setUserAnswers(List<String> userAnswers) {
7780
for (int i = 0; i < userAnswers.size(); i++) {
7881
QuizQuestion q = this.quizQuestions.get(i);
@@ -81,6 +84,10 @@ public void setUserAnswers(List<String> userAnswers) {
8184
}
8285
}
8386

87+
/**
88+
* Gets the actual answers.
89+
* @return the actual answers
90+
*/
8491
public List<String> getActualAnswers() {
8592
List<String> actualAnswers = new ArrayList<>();
8693
for (QuizQuestion q : this.quizQuestions) {
@@ -89,14 +96,26 @@ public List<String> getActualAnswers() {
8996
return actualAnswers;
9097
}
9198

99+
/**
100+
* Gets the quiz questions.
101+
* @return the quiz questions
102+
*/
92103
public List<QuizQuestion> getQuizQuestions() {
93104
return this.quizQuestions;
94105
}
95106

107+
/**
108+
* Gets the quiz score.
109+
* @return the score
110+
*/
96111
public int getScore() {
97112
return this.score;
98113
}
99114

115+
/**
116+
* Gets the number of questions.
117+
* @return the number of questions
118+
*/
100119
public int getNumQuestions() {
101120
return this.quizQuestions.size();
102121
}

src/main/java/entities/QuizQuestion.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,22 @@ public boolean isCorrect(){
2727
return this.actualAnswer.equalsIgnoreCase(this.userAnswer);
2828
}
2929

30-
/** GETTERS AND SETTERS **/
30+
/**
31+
* Gets the actual answer.
32+
* @return the actual answer
33+
*/
3134
public String getActualAnswer() {
3235
return actualAnswer;
3336
}
3437

38+
/**
39+
* Sets the actual answer.
40+
* @param actualAnswer the actual answer
41+
*/
3542
public void setActualAnswer(String actualAnswer) {
3643
this.actualAnswer = actualAnswer;
3744
}
3845

39-
public String getUserAnswer() {
40-
return userAnswer;
41-
}
42-
4346
/**
4447
* Sets the user answer. If the user answer is null or empty, the user answer should be set to null.
4548
* @param userAnswer the user answer

src/main/java/entities/QuizSettings.java

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* @author Anthony
66
*/
77
public class QuizSettings {
8-
private int numQuestions;
9-
private boolean timerOn;
10-
private int timerDuration;
11-
private boolean multipleChoiceOn;
12-
private boolean textEntryOn;
13-
private boolean trueFalseOn;
8+
private final int numQuestions;
9+
private final boolean timerOn;
10+
private final int timerDuration;
11+
private final boolean multipleChoiceOn;
12+
private final boolean textEntryOn;
13+
private final boolean trueFalseOn;
1414

1515
/**
1616
* Constructor for quiz settings.
@@ -45,52 +45,35 @@ public boolean timerIsReasonable() {
4545
return ((1 <= this.timerDuration && this.timerDuration <= 60) || !(this.timerOn));
4646
}
4747

48-
/** GETTERS AND SETTERS **/
48+
/**
49+
* Gets the number of questions.
50+
* @return the number of questions
51+
*/
4952
public int getNumQuestions() {
5053
return numQuestions;
5154
}
5255

53-
public void setNumQuestions(int numQuestions) {
54-
this.numQuestions = numQuestions;
55-
}
56-
57-
public boolean isTimerOn() {
58-
return timerOn;
59-
}
60-
61-
public void setTimerOn(boolean timerOn) {
62-
this.timerOn = timerOn;
63-
}
64-
65-
public int getTimerDuration() {
66-
return timerDuration;
67-
}
68-
69-
public void setTimerDuration(int timerDuration) {
70-
this.timerDuration = timerDuration;
71-
}
72-
56+
/**
57+
* Gets the multiple choice boolean value.
58+
* @return true if multiple choice is on
59+
*/
7360
public boolean isMultipleChoiceOn() {
7461
return multipleChoiceOn;
7562
}
7663

77-
public void setMultipleChoiceOn(boolean multipleChoiceOn) {
78-
this.multipleChoiceOn = multipleChoiceOn;
79-
}
80-
64+
/**
65+
* Gets the text entry boolean value.
66+
* @return true if text entry is on
67+
*/
8168
public boolean isTextEntryOn() {
8269
return textEntryOn;
8370
}
8471

85-
public void setTextEntryOn(boolean textEntryOn) {
86-
this.textEntryOn = textEntryOn;
87-
}
88-
72+
/**
73+
* Gets the true/false boolean value.
74+
* @return true if true/false is on
75+
*/
8976
public boolean isTrueFalseOn() {
9077
return trueFalseOn;
9178
}
92-
93-
public void setTrueFalseOn(boolean trueFalseOn) {
94-
this.trueFalseOn = trueFalseOn;
95-
}
9679
}

src/main/java/entities/TextEntryQuestion.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class TextEntryQuestion extends QuizQuestion {
1414

1515
private static final Random rand = new Random();
1616

17+
/**
18+
* Constructs a text entry question.
19+
* @param flashcards the list of flashcards
20+
* @param index the index of a specific flashcard
21+
*/
1722
public TextEntryQuestion(List<Flashcard> flashcards, int index) {
1823
this.missingTerm = rand.nextBoolean();
1924
generateQuestion(flashcards, index);
@@ -36,6 +41,10 @@ public void generateQuestion(List<Flashcard> flashcards, int index) {
3641
}
3742
}
3843

44+
/**
45+
* Returns the string representation of the text entry question.
46+
* @return string representation
47+
*/
3948
@Override
4049
public String toString() {
4150
if (this.missingTerm) {
@@ -45,24 +54,35 @@ public String toString() {
4554
}
4655
}
4756

48-
/** GETTERS AND SETTERS **/
57+
/**
58+
* Gets the term.
59+
* @return the term
60+
*/
4961
public String getTerm() {
5062
return term;
5163
}
5264

65+
/**
66+
* Sets the term.
67+
* @param term the term
68+
*/
5369
public void setTerm(String term) {
5470
this.term = term;
5571
}
5672

73+
/**
74+
* Gets the definition.
75+
* @return the definition.
76+
*/
5777
public String getDefinition() {
5878
return definition;
5979
}
6080

81+
/**
82+
* Sets the definition.
83+
* @param definition the definition
84+
*/
6185
public void setDefinition(String definition) {
6286
this.definition = definition;
6387
}
64-
65-
public boolean isMissingTerm() {
66-
return missingTerm;
67-
}
6888
}

src/main/java/entities/TrueFalseQuestion.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class TrueFalseQuestion extends QuizQuestion {
1414

1515
private static final Random rand = new Random();
1616

17+
/**
18+
* Constructs a true/false question.
19+
* @param flashcards the list of flashcards
20+
* @param index the index of a specific flashcard
21+
*/
1722
public TrueFalseQuestion(List<Flashcard> flashcards, int index) {
1823
this.pranked = rand.nextBoolean();
1924
generateQuestion(flashcards, index);
@@ -40,6 +45,10 @@ public void generateQuestion(List<Flashcard> flashcards, int index) {
4045
this.potentialDefinition = flashcard.getDefinition();
4146
}
4247

48+
/**
49+
* Returns the string representation of the true/false question.
50+
* @return string representation
51+
*/
4352
@Override
4453
public String toString() {
4554
return ("TRUE OR FALSE?\nTerm: " + this.term + "\nDefinition: " + this.potentialDefinition);
@@ -59,20 +68,27 @@ public static int randomExcluded(int max, int excluded) {
5968
return n;
6069
}
6170

62-
/** GETTERS AND SETTERS **/
71+
/**
72+
* Gets the term.
73+
* @return the term
74+
*/
6375
public String getTerm() {
6476
return term;
6577
}
6678

79+
/**
80+
* Sets the term.
81+
* @param term the term
82+
*/
6783
public void setTerm(String term) {
6884
this.term = term;
6985
}
7086

87+
/**
88+
* Gets the potential definition.
89+
* @return the potential definition
90+
*/
7191
public String getPotentialDefinition() {
7292
return potentialDefinition;
7393
}
74-
75-
public void setPotentialDefinition(String potentialDefinition) {
76-
this.potentialDefinition = potentialDefinition;
77-
}
7894
}

0 commit comments

Comments
 (0)