Skip to content

Commit

Permalink
Refactor code slightly for java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
LIN_CHIEH committed Feb 19, 2023
1 parent 40f0a33 commit 84d3c5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 17 additions & 7 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,23 @@ public Message respondToMessage(Message msg) throws DukeException {
}

String command = tokens[0];
return switch (command) {
case "list", "find" -> handleDisplayCommand(tokens);
case "mark", "unmark", "tag" -> handleEditCommand(tokens);
case "todo", "deadline", "event" -> handleAddCommand(tokens);
case "delete" -> handleDeleteCommand(tokens);
default -> handleUnknownCommand(tokens);
};
switch (command) {
case "list":
case "find":
return handleDisplayCommand(tokens);
case "mark":
case "unmark":
case "tag":
return handleEditCommand(tokens);
case "todo":
case "deadline":
case "event":
return handleAddCommand(tokens);
case "delete":
return handleDeleteCommand(tokens);
default:
return handleUnknownCommand(tokens);
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/duke/ui/UiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public UiController(Duke context) {
* Displays welcome message from Duke on GUI.
*/
public void displayWelcomeMessage() {
String welcomeText = """
Welcome! My name is Duke.
How may I help?""";
String welcomeText = "Welcome! My name is Duke.\nHow may I help?";
fxmlLoader.<MainWindow>getController().displayDukeDialog(welcomeText);
}

Expand Down

0 comments on commit 84d3c5a

Please sign in to comment.