Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S2#34 from Ijaaz01/MohamedIjaaz-A…
Browse files Browse the repository at this point in the history
…ssert

Fix format of help message and add assert to info command parser
  • Loading branch information
Ijaaz01 authored Mar 20, 2024
2 parents cd49c1c + 5a8f26d commit 2dd437e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ checkstyle {

run{
standardInput = System.in
enableAssertions = false;
}
3 changes: 3 additions & 0 deletions src/main/java/florizz/command/FlowerCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package florizz.command;

import florizz.core.FlorizzException;
import florizz.core.OccasionDictionary;
import florizz.core.Ui;
import florizz.objects.Bouquet;

Expand All @@ -17,6 +18,8 @@ public FlowerCommand(String occasion) {
public boolean execute(ArrayList<Bouquet> bouquetList, Ui ui) throws FlorizzException {
if (occasion.isBlank()) {
ui.printAllDictFlowerName();
} else if (!OccasionDictionary.contains(occasion)){
throw new FlorizzException("This occasion does not exist type 'occasion' to get a list of occasions");
} else {
ui.printOccasionFlower(occasion);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/florizz/core/OccasionDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void add(String Occasion) {

public static void startup() {
for (int i = 0; i < FlowerDictionary.size(); i++) {
add(FlowerDictionary.get(i).getOccasion());
add(FlowerDictionary.get(i).getOccasion().toLowerCase());
}
}

Expand All @@ -25,4 +25,8 @@ public static void print() {
System.out.println(occasion);
}
}

public static boolean contains(String occasion) {
return uniqueOccasions.contains(occasion.toLowerCase());
}
}
1 change: 1 addition & 0 deletions src/main/java/florizz/core/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private static FlowerCommand handleFlowerCommand(String input) {

private static InfoCommand handleInfoCommand(String input) {
String flowerName = input.substring(input.indexOf(" ") + 1);
assert !flowerName.isEmpty() : "This string is empty";
return new InfoCommand(flowerName);
}

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/florizz/core/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ public void printHelpMessage() {
System.out.println("1. new <bouquet_name> - Add a bouquet");
System.out.println("2. delete <bouquet_name> - Delete a bouquets");
System.out.println("3. mybouquets - List current saved bouquets");
System.out.println("4. flower <occasion_name> - List all flowers in Florizz or all flowers for an occasion");
System.out.println("5. info <flower_name> - Provide information on chosen flower");
System.out.println("6. flower - Shows a list of flowers that can be added into mybouquets");
System.out.println("7. flower <occasion> - Shows a list of flowers associated with said occasion");
System.out.println("8. bye - Exits the programme");
System.out.println("4. info <flower_name> - Provide information on chosen flower");
System.out.println("5. flower - Shows a list of flowers that can be added into mybouquets");
System.out.println("6. flower <occasion> - Shows a list of flowers associated with said occasion");
System.out.println("7. bye - Exits the programme");
printBreakLine();
}

Expand Down

0 comments on commit 2dd437e

Please sign in to comment.