From 9eb038c4ac7684bd56c0955730be34ffe72eb44a Mon Sep 17 00:00:00 2001 From: ChenKangg Date: Mon, 8 Apr 2024 21:11:01 +0800 Subject: [PATCH] update location + help command --- .../java/seedu/omnitravel/parser/Parser.java | 9 ++-- .../seedu/omnitravel/storage/FileSave.java | 1 + src/main/java/seedu/omnitravel/ui/Ui.java | 53 ++++++++++++++++++- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/omnitravel/parser/Parser.java b/src/main/java/seedu/omnitravel/parser/Parser.java index f476da4a42..d34f7a3056 100644 --- a/src/main/java/seedu/omnitravel/parser/Parser.java +++ b/src/main/java/seedu/omnitravel/parser/Parser.java @@ -377,10 +377,11 @@ public static void currencyExchangeCommand(String line) throws OmniException{ public static void locationCommand(String line, TravelActivityList list) throws OmniException { String[] command = line.split(" "); if (command.length >= 3 && CheckParameters.isNumeric(command[1])){ - String index = command[1]; - String[] locationSplit = line.split(index); - String location = locationSplit[1].trim(); - int listNumber = Integer.parseInt(index); + int listNumber = Integer.parseInt(command[1]); + // Extract location starting from the third element onwards + String[] locationArray = Arrays.copyOfRange(command, 2, command.length); + // Join the location into a single string + String location = String.join(" ", locationArray); list.locationActivity(listNumber, location); } else if (command.length == 2) { throw new OmniException("Please specify a location"); diff --git a/src/main/java/seedu/omnitravel/storage/FileSave.java b/src/main/java/seedu/omnitravel/storage/FileSave.java index f4bd1cc7e9..a493b1afe6 100644 --- a/src/main/java/seedu/omnitravel/storage/FileSave.java +++ b/src/main/java/seedu/omnitravel/storage/FileSave.java @@ -81,6 +81,7 @@ public void saveActivityList(TravelActivityList list) throws IOException { + " / " + travelActivity.getDuration() + " / " + travelActivity.getTag() + " / " + travelActivity.getExpense() + + " / " + travelActivity.getLocation() + System.lineSeparator()); } fw.close(); diff --git a/src/main/java/seedu/omnitravel/ui/Ui.java b/src/main/java/seedu/omnitravel/ui/Ui.java index 710b97c226..0e3ed3ac5a 100644 --- a/src/main/java/seedu/omnitravel/ui/Ui.java +++ b/src/main/java/seedu/omnitravel/ui/Ui.java @@ -62,26 +62,75 @@ public static void helpCommand(){ printLine(); System.out.println("These are the available commands!"); System.out.println(""); - System.out.println("1. list: List out the current list\n" + + System.out.println( + "1. list: List out the current list\n" + + "Format: `list`\n" + + "2. help: Get all commands for the chatbot\n" + + "Format: `help`\n" + + "3. bye: Exit the chatbot\n" + + "Format: `bye`\n" + + "4. add \n" + + "Format: `add DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`\n" + + "5. accommodation \n" + + "Format: `accommodation DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`\n" + + "6. food \n" + + "Format: `food DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`\n" + + "7. landmark \n" + + "Format: `landmark DESCRIPTION /date YYYY-MM-DD /duration DURATION [/tag TAG]`\n" + + "8. delete \n" + + "Format: `delete INDEX`\n" + + "9. find \n" + + "Format: `find DESCRIPTION`\n" + + "10. check \n" + + "Format: `check INDEX`\n" + + "11. uncheck \n" + + "Format: `uncheck INDEX`\n" + + "12. tag \n" + + "Format: `tag INDEX TAGNAME`\n" + + "13. untag \n" + + "Format: `untag INDEX`\n" + + "14. update \n" + + "Format: `update INDEX /date YYYY-MM-DD /duration DURATION [/tag TAG]`\n" + + "15. findtag \n" + + "Format: `findtag TAG`\n" + + "16. findtype \n" + + "Format: `findtype TYPE`\n" + + "17. expense \n" + + "Format: `expense INDEX EXPENSE`\n" + + "18. removeexpense \n" + + "Format: `removeexpense INDEX`\n" + + "19. totalexpense \n" + - "20. change /from /to "); + "Format: `totalexpense [/type TYPE]`\n" + + + "20. change /from /to \n" + + "Format: `change AMOUNT /from CODE /to CODE`\n" + + + "21. location \n" + + "Format: `location INDEX LOCATION`\n" + + + "22. removelocation \n" + + "Format: `removelocation INDEX`\n" + + + "23. findlocation \n" + + "Format: `findlocation LOCATION`\n"); printLine(); }