diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6e864153e8 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: duke.Duke + diff --git a/build.gradle b/build.gradle index e1ac861ebb..5483f354bc 100644 --- a/build.gradle +++ b/build.gradle @@ -54,14 +54,11 @@ test { } application { - mainClass.set("duke.Duke") + mainClass.set("Launcher") } shadowJar { - archiveFileName = "duke.jar" - archiveBaseName = "duke" - archiveClassifier = null - dependsOn("distZip", "distTar") + archiveFileName = "ken.jar" } run{ diff --git a/data/duke.txt b/data/duke.txt index e68e4b4602..94dc37c96d 100644 --- a/data/duke.txt +++ b/data/duke.txt @@ -1 +1,7 @@ +T|false|test +T|false|a +T|false|a +T|false|a +T|false|a +T|false|test T|false|1 diff --git a/src/main/java/Launcher.java b/src/main/java/Launcher.java new file mode 100644 index 0000000000..e07e6824c6 --- /dev/null +++ b/src/main/java/Launcher.java @@ -0,0 +1,11 @@ +import duke.Duke; +import javafx.application.Application; + +/** + * Launcher for stating the program with gui. + */ +public class Launcher { + public static void main(String[] args) { + Application.launch(Duke.class, args); + } +} diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 6273914b0a..efddaf76a6 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -37,10 +37,6 @@ public class Duke extends Application { private Image user = new Image(this.getClass().getResourceAsStream("/images/DaUser.png")); private Image duke = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png")); - public static void main(String[] args) { - Application.launch(Duke.class, args); - } - /** * Start the program with GUI. * diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java index dbbc425da3..29af25341c 100644 --- a/src/main/java/duke/Parser.java +++ b/src/main/java/duke/Parser.java @@ -24,7 +24,7 @@ public class Parser { * @return The corresponding duke.command.Command object. */ public static Command parse(String userInput) throws DukeException { - String[] words = userInput.toLowerCase().split("\\s+"); + String[] words = userInput.trim().toLowerCase().split("\\s+"); switch (words[0]) { case "bye": return new ExitCommand(); diff --git a/src/main/java/duke/command/AddCommand.java b/src/main/java/duke/command/AddCommand.java index 63978574d3..a613f1e332 100644 --- a/src/main/java/duke/command/AddCommand.java +++ b/src/main/java/duke/command/AddCommand.java @@ -25,7 +25,7 @@ public class AddCommand implements Command { */ @Override public boolean execute(TaskList tasks, Ui ui) throws DukeException { - String userInput = ui.getLastMsg(); + String userInput = ui.getLastMsg().trim(); // Determine the task type based on the message. if (userInput.toLowerCase().startsWith("todo")) { diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..8a51453653 --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Launcher + diff --git a/src/test/java/ParserTest.java b/src/test/java/ParserTest.java index 4229729ba1..e1a9f77e20 100644 --- a/src/test/java/ParserTest.java +++ b/src/test/java/ParserTest.java @@ -31,4 +31,18 @@ public void parse_unknownCommand_exceptionThrown() { assertEquals(true, true); } } + + @Test + public void parse_handleMultipleSpaces() { + String[] testInputs = {" bye", " bye ", " bye"}; + String lastInput = testInputs[0]; + try { + for (String command : testInputs) { + lastInput = command; + Parser.parse(command); + } + } catch (DukeException e) { + fail(lastInput + " command failed to parse"); + } + } }