@@ -104,14 +104,19 @@ public QuizScreen(QuizController controller, QuizSettingsResponseModel response,
104
104
}
105
105
106
106
/**
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
110
112
*/
111
113
@ Override
112
114
public void actionPerformed (ActionEvent e ) {
113
115
String command = e .getActionCommand ();
114
116
if (command .equals (Actions .RESTART .name ())) {
117
+ if (timer != null ) {
118
+ timer .stop ();
119
+ }
115
120
this .setVisible (false );
116
121
this .dispose ();
117
122
new QuizSettingsScreen (this .controller , this .flashcardSetID );
@@ -126,11 +131,20 @@ public void actionPerformed(ActionEvent e) {
126
131
int input = JOptionPane .showConfirmDialog (null , message ,
127
132
"WARNING" , JOptionPane .YES_NO_OPTION );
128
133
if (input == 0 ) { // continue onwards
134
+ if (timer != null ) {
135
+ timer .stop ();
136
+ }
137
+
138
+ // transition into next screen
129
139
this .setVisible (false );
130
140
this .dispose ();
131
141
new QuizResultsScreen (this .controller , response , this .flashcardSetID );
132
142
}
133
143
} else {
144
+ if (timer != null ) {
145
+ timer .stop ();
146
+ }
147
+
134
148
// transition into next screen
135
149
this .setVisible (false );
136
150
this .dispose ();
0 commit comments