From 009a7e2bf22ec06ce092a7dd33a2822574b035f5 Mon Sep 17 00:00:00 2001 From: Jia En Date: Mon, 19 Feb 2024 21:24:28 +0800 Subject: [PATCH] Fix regressions --- src/main/java/chatbot/Command.java | 2 +- src/main/java/chatbot/Parser.java | 6 +++--- src/main/java/chatbot/controllers/DialogBox.java | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/chatbot/Command.java b/src/main/java/chatbot/Command.java index 27ad8947c6..425ab4b6f3 100644 --- a/src/main/java/chatbot/Command.java +++ b/src/main/java/chatbot/Command.java @@ -52,7 +52,7 @@ public void withArgs(String args) { @Override public String toString() { - return this.rep + this.args; + return this.rep; } /** diff --git a/src/main/java/chatbot/Parser.java b/src/main/java/chatbot/Parser.java index dc9d635426..490a994486 100644 --- a/src/main/java/chatbot/Parser.java +++ b/src/main/java/chatbot/Parser.java @@ -32,12 +32,12 @@ public class Parser { public static Command toCommand(String rep) throws InvalidCommandException, InvalidArgumentException { String[] split = rep.split("\\s+", 2); Command cmd = cmdStrMap.get(split[0]); - if (split.length > 1 && cmd.hasArgs()) { - cmd.withArgs(split[1]); - } if (cmd == null) { throw new InvalidCommandException(); } + if (split.length > 1 && cmd.hasArgs()) { + cmd.withArgs(split[1]); + } if (split.length > 1 && !cmd.hasArgs()) { throw new InvalidArgumentException(); } diff --git a/src/main/java/chatbot/controllers/DialogBox.java b/src/main/java/chatbot/controllers/DialogBox.java index cf8d8fbaf3..7002b47e00 100644 --- a/src/main/java/chatbot/controllers/DialogBox.java +++ b/src/main/java/chatbot/controllers/DialogBox.java @@ -13,6 +13,7 @@ import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; @@ -67,6 +68,6 @@ private void flip() { Collections.reverse(tmp); message.getChildren().setAll(tmp); setAlignment(Pos.TOP_LEFT); - messageBg.setBackground(Background.fill(Color.web("#F8EDFF"))); + messageBg.setBackground(new Background(new BackgroundFill(Color.web("#F8EDFF"), null, null))); } }