Skip to content

Commit

Permalink
Fix behaviour for Bye command
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobkwan committed Oct 16, 2022
1 parent 6c8087b commit d86fb8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/duke/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Encapsulates a command to terminate Duke.
*/
public class ExitCommand extends Command {
public static final String EXIT_RESPONSE = "bye...";

/**
* Executes the ExitCommand to terminate Duke.
*
Expand All @@ -17,7 +19,7 @@ public class ExitCommand extends Command {
*/
@Override
public String execute(TaskList tasks, Ui ui, Storage storage) {
return "bye...";
return EXIT_RESPONSE;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/duke/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.IOException;

import duke.Duke;
import duke.command.ExitCommand;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
Expand Down Expand Up @@ -66,5 +68,8 @@ private void handleUserInput() {
dialogContainer.getChildren().addAll(DialogBox.getUserDialog(input, userImage),
DialogBox.getDukeDialog(response, dukeImage));
userInput.clear();
if (response == ExitCommand.EXIT_RESPONSE) {
Platform.exit();
}
}
}

0 comments on commit d86fb8c

Please sign in to comment.