Skip to content

Commit cdb3c21

Browse files
timer bug
1 parent 10071ca commit cdb3c21

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main/java/quiz_use_case/screens/QuizScreen.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,19 @@ public QuizScreen(QuizController controller, QuizSettingsResponseModel response,
104104
}
105105

106106
/**
107-
* RESTART - the program returns to the quiz settings screen.
108-
* SUBMIT - the program collects all user answers and proceeds to the quiz results screen.
109-
* @param e the action event
107+
* RESTART the program returns to the quiz settings screen.
108+
* SUBMIT the program collects all user answers and proceeds to the quiz results screen.
109+
* UPDATE_TIMER the program updates the timer. If the timer runs out of time, then the program automatically
110+
* proceeds to the quiz results screen without any user input.
111+
* @param e the action event
110112
*/
111113
@Override
112114
public void actionPerformed(ActionEvent e) {
113115
String command = e.getActionCommand();
114116
if (command.equals(Actions.RESTART.name())) {
117+
if (timer != null) {
118+
timer.stop();
119+
}
115120
this.setVisible(false);
116121
this.dispose();
117122
new QuizSettingsScreen(this.controller, this.flashcardSetID);
@@ -126,11 +131,20 @@ public void actionPerformed(ActionEvent e) {
126131
int input = JOptionPane.showConfirmDialog(null, message,
127132
"WARNING", JOptionPane.YES_NO_OPTION);
128133
if (input == 0) { // continue onwards
134+
if (timer != null) {
135+
timer.stop();
136+
}
137+
138+
// transition into next screen
129139
this.setVisible(false);
130140
this.dispose();
131141
new QuizResultsScreen(this.controller, response, this.flashcardSetID);
132142
}
133143
} else {
144+
if (timer != null) {
145+
timer.stop();
146+
}
147+
134148
// transition into next screen
135149
this.setVisible(false);
136150
this.dispose();

0 commit comments

Comments
 (0)