Skip to content

Commit

Permalink
Re-add assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ijaaz01 committed Apr 9, 2024
1 parent 66c278c commit a422521
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/florizz/command/SaveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public SaveCommand(String bouquetName) {
*/
@Override
public boolean execute(ArrayList<Bouquet> 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 <BOUQUETNAME>'");
throw new FlorizzException("This bouquet does not exist. Create it by typing 'new <bouquetName>'");
}
Storage storage = new Storage();
try {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/florizz/core/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a422521

Please sign in to comment.