From a422521a3c23f9c6ceb982f3417ab4245a216a9b Mon Sep 17 00:00:00 2001 From: "LAPTOP-6F19PDN9\\Ijaaz" Date: Tue, 9 Apr 2024 15:12:46 +0800 Subject: [PATCH] Re-add assertion --- src/main/java/florizz/command/SaveCommand.java | 3 ++- src/main/java/florizz/core/Parser.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/florizz/command/SaveCommand.java b/src/main/java/florizz/command/SaveCommand.java index c40e8937f4..b1a3064ebe 100644 --- a/src/main/java/florizz/command/SaveCommand.java +++ b/src/main/java/florizz/command/SaveCommand.java @@ -32,9 +32,10 @@ public SaveCommand(String bouquetName) { */ @Override public boolean execute(ArrayList bouquetList, Ui ui) throws FlorizzException { + assert !bouquetName.isEmpty() : "bouquet name cannot be empty"; int bouquetIdx = bouquetList.indexOf(new Bouquet(bouquetName)); if (bouquetIdx == -1) { - throw new FlorizzException("This bouquet does not exist. Create it by typing 'new '"); + throw new FlorizzException("This bouquet does not exist. Create it by typing 'new '"); } Storage storage = new Storage(); try { diff --git a/src/main/java/florizz/core/Parser.java b/src/main/java/florizz/core/Parser.java index a65cee151e..cfdb24ec0a 100644 --- a/src/main/java/florizz/core/Parser.java +++ b/src/main/java/florizz/core/Parser.java @@ -116,7 +116,7 @@ public static String[] commandHandler(String input) throws FlorizzException { if (firstWhitespace != -1) { outputs[0] = FuzzyLogic.detectItem(trimmedInput.substring(0,firstWhitespace).toLowerCase()); switch (outputs[0]) { - case ("save"): + case ("save"): // Fallthrough case ("delete"): // Fallthrough case ("new"): outputs[1] = trimmedInput.substring(firstWhitespace).trim(); @@ -145,9 +145,9 @@ public static String[] commandHandler(String input) throws FlorizzException { outputs[0] = FuzzyLogic.detectItem(trimmedInput.toLowerCase()); } - if (firstWhitespace == -1 && (outputs[0].equals("save"))) { + /*if (firstWhitespace == -1 && (outputs[0].equals("save"))) { throw new FlorizzException("Please specify which bouquet you are saving!"); - } + }*/ return outputs; }