diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index cd902f9ccf..dcc3806e6c 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,8 +1,6 @@ package duke; -import duke.gui.MainWindow; import duke.task.TaskList; -import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import java.io.FileNotFoundException; @@ -12,12 +10,12 @@ * Represents an intelligent chat robot that helps a person to keep track of various things with encouraging quotes. */ public class Duke { + private static final String SAVING_ERROR_MSG = "⚠ Oops! Something wrong when closing:("; + private static final String BYE_MSG = "Bye!\n\"Beware the barrenness of a busy life.\""; private Parser parser; private Storage storage; private TaskList tasks; private Stage stage; - public String SAVING_ERROR_MSG = "⚠ Oops! Something wrong when closing:("; - public String BYE_MSG = "Bye!\n\"Beware the barrenness of a busy life.\""; /** * Initializes the chat robot. Establishes task list and parser. @@ -50,7 +48,7 @@ public String getResponse(String input) { } } - public void close(){ + public void close() { this.stage.close(); } diff --git a/src/main/java/duke/gui/MainWindow.java b/src/main/java/duke/gui/MainWindow.java index 273a3afcbe..c79e0616d0 100644 --- a/src/main/java/duke/gui/MainWindow.java +++ b/src/main/java/duke/gui/MainWindow.java @@ -15,6 +15,9 @@ * Controller for MainWindow. Provides the layout for the other controls. */ public class MainWindow extends AnchorPane { + private static final String WELCOME_MSG = "Hi! This is your intelligent friend L.\n\"Dream big.\"\n" + + "What can I do for you today?"; + private static final String BYE_MSG = "Bye!\n\"Beware the barrenness of a busy life.\""; @FXML private ScrollPane scrollPane; @FXML @@ -26,9 +29,10 @@ public class MainWindow extends AnchorPane { private Duke duke; private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.jpg")); private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.jpg")); - private String WELCOME_MSG = "Hi! This is your intelligent friend L.\n\"Dream big.\"\n" - + "What can I do for you today?"; + /** + * Initializes the main window. + */ @FXML public void initialize() { scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); @@ -54,7 +58,7 @@ private void handleUserInput() { DialogBox.getDukeDialog(response, dukeImage) ); userInput.clear(); - if (response.equals(duke.BYE_MSG)){ + if (response.equals(BYE_MSG)) { // Close the window after 5 seconds PauseTransition pause = new PauseTransition(Duration.seconds(5)); pause.setOnFinished(event -> duke.close()); diff --git a/src/test/java/duke/ParserTest.java b/src/test/java/duke/ParserTest.java index 4019dc540e..113310f111 100644 --- a/src/test/java/duke/ParserTest.java +++ b/src/test/java/duke/ParserTest.java @@ -8,13 +8,14 @@ public class ParserTest { @Test - public void parse_bye_success() throws DukeException{ + public void parse_bye_success() throws DukeException { assertEquals("", new Parser(null).parse("88")); } @Test public void parse_undefinedInput_exceptionThrown() { - try{ - assertEquals("⚠ Sorry! I am not able to understand you. Try another language:D", new Parser(null).parse("undefined")); + try { + assertEquals("⚠ Sorry! I am not able to understand you. Try another language:D", + new Parser(null).parse("undefined")); fail(); } catch (DukeException e) { assertEquals("undefined", e.getMessage()); diff --git a/src/test/java/duke/task/TaskListTest.java b/src/test/java/duke/task/TaskListTest.java index 55e3711121..e611900cf3 100644 --- a/src/test/java/duke/task/TaskListTest.java +++ b/src/test/java/duke/task/TaskListTest.java @@ -10,7 +10,7 @@ public class TaskListTest { @Test public void markTask_negativeIndex_exceptionThrown() { try { - assertEquals("⚠ OOPS!!! The task index is out of range.", new TaskList().markTask(-1,true)); + assertEquals("⚠ OOPS!!! The task index is out of range.", new TaskList().markTask(-1, true)); fail(); } catch (Exception e) { assertEquals("task not found", e.getMessage());