From 686eec490c430bc061cb46871d35883b4bddcf9e Mon Sep 17 00:00:00 2001 From: daryltay415 <13zidane@gmail.com> Date: Sun, 14 Apr 2024 13:50:27 +0800 Subject: [PATCH 1/5] Add javadocs --- docs/DeveloperGuide.md | 8 ++++---- .../seedu/omnitravel/errorhandlers/CheckParameters.java | 2 +- .../seedu/omnitravel/exchangerateapi/CurrencyRate.java | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 06ce2cc50d..5bf2794776 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -324,11 +324,11 @@ The instructions given below are used for testing the app manually. Expected: The current activity list will be shown without any sorting order - 2. Test case: `list /date 2024-12-12` + 2. Test case: `list /date 2024-12-12` Expected: All the activities with the date 2024-12-12 will be shown - 3. Test case: `list /sort` + 3. Test case: `list /sort` Expected: All the activities will be shown in a list by ascending dates @@ -406,7 +406,7 @@ The instructions given below are used for testing the app manually. Expected: No expense is removed and an error message will be shown. ### Converting currency -1. Converting a local curreny to a foreign currency +1. Converting a local currency to a foreign currency 1. Test case: `change 100 /from sgd /to jyp` Expected: The conversion of 100 singapore dollars to japanese yen will be shown @@ -477,4 +477,4 @@ The instructions given below are used for testing the app manually. 1. Shows all the commands the user can input 1. Test case: `help` - Expected: All the commands and their format will be shown \ No newline at end of file + Expected: All the commands will be shown \ No newline at end of file diff --git a/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java b/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java index 9672cebecb..0e2ebcf765 100644 --- a/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java +++ b/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java @@ -110,7 +110,7 @@ public static void containsWords(String input) throws OmniException{ } } throw new OmniException("Your duration is invalid. Please input in terms of \"1 " + - "day, week, month, year, hour, minutue or second\""); + "day/s, week/s, month/s, year/s, hour/s, minutue/s or second/s\""); } /** diff --git a/src/main/java/seedu/omnitravel/exchangerateapi/CurrencyRate.java b/src/main/java/seedu/omnitravel/exchangerateapi/CurrencyRate.java index 8b0c01f596..f0bb1cd03f 100644 --- a/src/main/java/seedu/omnitravel/exchangerateapi/CurrencyRate.java +++ b/src/main/java/seedu/omnitravel/exchangerateapi/CurrencyRate.java @@ -8,6 +8,10 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; +/** + * Represents the currency exchange api + * It contains methods that uses the currency exchange api to exchange one currency to another + */ public class CurrencyRate { //@@author daryltay415 /** From b20066d8cf3de9e01e24ba494e288c6988afcc44 Mon Sep 17 00:00:00 2001 From: daryltay415 <13zidane@gmail.com> Date: Sun, 14 Apr 2024 14:33:59 +0800 Subject: [PATCH 2/5] Update ppp --- docs/AboutUs.md | 14 +- docs/DeveloperGuide.md | 19 ++- .../ArchitectureDiagram.png | Bin docs/{ => DiagramImages}/Errorhandler.png | Bin docs/{ => DiagramImages}/Overview.png | Bin .../TagSequenceDiagram.png | Bin .../TravelActivityTypeClassDiagram.png | Bin .../UpdateFeatureClassDiagram.png | Bin docs/{ => DiagramImages}/img.png | Bin docs/{ => DiagramImages}/img_1.png | Bin docs/{ => DiagramImages}/img_2.png | Bin docs/{ => DiagramImages}/img_3.png | Bin docs/{ => DiagramImages}/lookupFunctions.png | Bin docs/{ => DiagramImages}/totalexpense.png | Bin .../ArchitectureDiagram.puml | 46 +++--- .../Errorhandler.puml | 58 ++++---- .../FileSaveSequence.puml | 120 ++++++++-------- .../FileSaveUML.puml | 58 ++++---- .../{team => plantUML diagrams}/Overview.puml | 0 .../TagSequenceDiagram.puml | 48 +++---- .../TravelActivityTypeClassDiagram.puml | 48 +++---- .../UpdateFeatureClassDiagram.puml | 62 ++++---- .../UpdateSequenceDiagram.puml | 0 .../lookupFunctions.puml | 132 +++++++++--------- .../{ => plantUML diagrams}/totalexpense.puml | 38 ++--- docs/team/daryltay415.md | 89 ++++++------ 26 files changed, 367 insertions(+), 365 deletions(-) rename docs/{ => DiagramImages}/ArchitectureDiagram.png (100%) rename docs/{ => DiagramImages}/Errorhandler.png (100%) rename docs/{ => DiagramImages}/Overview.png (100%) rename docs/{ => DiagramImages}/TagSequenceDiagram.png (100%) rename docs/{ => DiagramImages}/TravelActivityTypeClassDiagram.png (100%) rename docs/{ => DiagramImages}/UpdateFeatureClassDiagram.png (100%) rename docs/{ => DiagramImages}/img.png (100%) rename docs/{ => DiagramImages}/img_1.png (100%) rename docs/{ => DiagramImages}/img_2.png (100%) rename docs/{ => DiagramImages}/img_3.png (100%) rename docs/{ => DiagramImages}/lookupFunctions.png (100%) rename docs/{ => DiagramImages}/totalexpense.png (100%) rename docs/{team => plantUML diagrams}/ArchitectureDiagram.puml (94%) rename docs/{team => plantUML diagrams}/Errorhandler.puml (91%) rename docs/{team => plantUML diagrams}/FileSaveSequence.puml (97%) rename docs/{team => plantUML diagrams}/FileSaveUML.puml (96%) rename docs/{team => plantUML diagrams}/Overview.puml (100%) rename docs/{team => plantUML diagrams}/TagSequenceDiagram.puml (96%) rename docs/{team => plantUML diagrams}/TravelActivityTypeClassDiagram.puml (93%) rename docs/{team => plantUML diagrams}/UpdateFeatureClassDiagram.puml (95%) rename docs/{team => plantUML diagrams}/UpdateSequenceDiagram.puml (100%) rename docs/{ => plantUML diagrams}/lookupFunctions.puml (97%) rename docs/{ => plantUML diagrams}/totalexpense.puml (95%) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 23898baed0..b0ee8a13ac 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -1,9 +1,9 @@ # About us -Display | Name | Github Profile | Portfolio ---------|:-------------------:|:---------------------------------------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | Eugene Chan Jiajun | [Github](https://github.com/EugeneChanJiajun) | [Portfolio](docs/team/eugenechanjiajun.md) -![](https://via.placeholder.com/100.png?text=Photo) | Daryl Tay | [Github](https://github.com/daryltay415) | [Portfolio](docs/team/daryltay415.md) -![](https://via.placeholder.com/100.png?text=Photo) | Annie Xu | [Github](https://github.com/annnniexu) | [Portfolio](docs/team/annnniexu.md) -![](https://via.placeholder.com/100.png?text=Photo) | Chin Yan Xu | [Github](https://github.com/ChinYanXu) | [Portfolio](docs/team/ChinYanXu.md) -![](https://via.placeholder.com/100.png?text=Photo) | Chen Kang | [Github](https://github.com/ChenKangg) | [Portfolio](docs/team/ChenKangg.md) +| Display | Name | Github Profile | Portfolio | +|----------------------------------------------------:|:------------------:|:---------------------------------------------:|:-------------------------------------:| +| ![](https://via.placeholder.com/100.png?text=Photo) | Eugene Chan Jiajun | [Github](https://github.com/EugeneChanJiajun) | [Portfolio](team/eugenechanjiajun.md) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Daryl Tay | [Github](https://github.com/daryltay415) | [Portfolio](team/daryltay415.md) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Annie Xu | [Github](https://github.com/annnniexu) | [Portfolio](team/annnniexu.md) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Chin Yan Xu | [Github](https://github.com/ChinYanXu) | [Portfolio](team/ChinYanXu.md) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Chen Kang | [Github](https://github.com/ChenKangg) | [Portfolio](team/ChenKangg.md) | diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index d66149dceb..588fb5d2e5 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -43,7 +43,7 @@ Source for currency exchange API: [link](https://github.com/fawazahmed0/exchange ## Design ### Architecture -![ArchitectureDiagram.png](ArchitectureDiagram.png) +![ArchitectureDiagram.png](DiagramImages/ArchitectureDiagram.png) The architecture diagram above describes the high level design of the OmniTravel app. @@ -82,7 +82,7 @@ The parser component, ### TravelActivityTypes component -![TravelActivityTypeClassDiagram.png](TravelActivityTypeClassDiagram.png) +![TravelActivityTypeClassDiagram.png](DiagramImages/TravelActivityTypeClassDiagram.png) The TravelActivityTypes component consists of a few different classes: * `Accommodation`: A subclass of travel activity related to accommodation @@ -105,7 +105,7 @@ the responses to the user. * takes in exceptions as parameters and prints out the error message. ### Errorhandlers component -![Errorhandlers.png](Errorhandler.png) +![Errorhandlers.png](DiagramImages/Errorhandler.png) The Errorhandler component consists of two classes `CheckParameters` and `OmniException`. `OmniException` is a subclass of the parent class `Exception`. @@ -135,12 +135,12 @@ the respective activity types and its contents with `/` as the delimiter. The Sequence Diagram below shows how the save file feature is being implemented when the user re-enters the chatbot after using the bye command. -![img.png](img.png) +![img.png](DiagramImages/img.png) The above sequence diagram shows how existing save text files will be reloaded back into Omnibots array list to act as a form of save feature when the user exits the bot. -![img_3.png](img_3.png) +![img_3.png](DiagramImages/img_3.png) The above class diagram shows the methods and the respective input and return types that the FileSave class contains. It also shows the classes called during the file load sequence. @@ -164,10 +164,10 @@ Step 3. The method will then find the travel activity with the corresponding tra of that travel activity. The class diagram below shows the main relationship between the classes in the update feature: -![UpdateFeatureClassDiagrma.png](UpdateFeatureClassDiagram.png) +![UpdateFeatureClassDiagrma.png](DiagramImages/UpdateFeatureClassDiagram.png) The sequence diagram below shows how an update operation goes through the parser component: -![img_1.png](img_1.png) +![img_1.png](DiagramImages/img_1.png) ### Total Expense feature @@ -184,7 +184,7 @@ Step 2. After the user has added new travel activities into the `travelActivityL Step 3. The method will loop through each activity in `travelActivities` and add up all the expenses for the given type. If no type is provided, it will default to TravelActivity type. -![totalexpense.png](totalexpense.png) +![totalexpense.png](DiagramImages/totalexpense.png) ### Tag feature @@ -192,7 +192,7 @@ The tag feature is implemented through the tagCommand method, which allows users The sequence diagram depicts the interaction between the user, the tagCommand method, the TravelActivityList instance, and the OmniException instance. -![TagSequenceDiagram.png](TagSequenceDiagram.png) +![TagSequenceDiagram.png](DiagramImages/TagSequenceDiagram.png) ## Appendix: Requirements ## Product scope ### Target user profile @@ -484,6 +484,5 @@ More info can be found in the user guide [here](https://ay2324s2-cs2113-t12-4.gi 1. Shows all the commands the user can input 1. Test case: `help` - Expected: All the commands will be shown diff --git a/docs/ArchitectureDiagram.png b/docs/DiagramImages/ArchitectureDiagram.png similarity index 100% rename from docs/ArchitectureDiagram.png rename to docs/DiagramImages/ArchitectureDiagram.png diff --git a/docs/Errorhandler.png b/docs/DiagramImages/Errorhandler.png similarity index 100% rename from docs/Errorhandler.png rename to docs/DiagramImages/Errorhandler.png diff --git a/docs/Overview.png b/docs/DiagramImages/Overview.png similarity index 100% rename from docs/Overview.png rename to docs/DiagramImages/Overview.png diff --git a/docs/TagSequenceDiagram.png b/docs/DiagramImages/TagSequenceDiagram.png similarity index 100% rename from docs/TagSequenceDiagram.png rename to docs/DiagramImages/TagSequenceDiagram.png diff --git a/docs/TravelActivityTypeClassDiagram.png b/docs/DiagramImages/TravelActivityTypeClassDiagram.png similarity index 100% rename from docs/TravelActivityTypeClassDiagram.png rename to docs/DiagramImages/TravelActivityTypeClassDiagram.png diff --git a/docs/UpdateFeatureClassDiagram.png b/docs/DiagramImages/UpdateFeatureClassDiagram.png similarity index 100% rename from docs/UpdateFeatureClassDiagram.png rename to docs/DiagramImages/UpdateFeatureClassDiagram.png diff --git a/docs/img.png b/docs/DiagramImages/img.png similarity index 100% rename from docs/img.png rename to docs/DiagramImages/img.png diff --git a/docs/img_1.png b/docs/DiagramImages/img_1.png similarity index 100% rename from docs/img_1.png rename to docs/DiagramImages/img_1.png diff --git a/docs/img_2.png b/docs/DiagramImages/img_2.png similarity index 100% rename from docs/img_2.png rename to docs/DiagramImages/img_2.png diff --git a/docs/img_3.png b/docs/DiagramImages/img_3.png similarity index 100% rename from docs/img_3.png rename to docs/DiagramImages/img_3.png diff --git a/docs/lookupFunctions.png b/docs/DiagramImages/lookupFunctions.png similarity index 100% rename from docs/lookupFunctions.png rename to docs/DiagramImages/lookupFunctions.png diff --git a/docs/totalexpense.png b/docs/DiagramImages/totalexpense.png similarity index 100% rename from docs/totalexpense.png rename to docs/DiagramImages/totalexpense.png diff --git a/docs/team/ArchitectureDiagram.puml b/docs/plantUML diagrams/ArchitectureDiagram.puml similarity index 94% rename from docs/team/ArchitectureDiagram.puml rename to docs/plantUML diagrams/ArchitectureDiagram.puml index e4ef5327f9..9e6b7756a1 100644 --- a/docs/team/ArchitectureDiagram.puml +++ b/docs/plantUML diagrams/ArchitectureDiagram.puml @@ -1,24 +1,24 @@ -@startuml -'https://plantuml.com/component-diagram - - - -Actor User as user - -user ..> [omnitravel] - -[omnitravel] --> "passes data"[parser] -[omnitravel] --> "Load/save"[storage] -[omnitravel] --> "uses" [ui] -[parser] --> "uses" [ui] -[parser] --> "uses" [exchangerateapi] -[parser] --> "uses" [errorhandlers] -[storage] --> "uses" [travelactivitytype] -[travelactivitytype] --> "uses" [ui] -[travelactivitytype] --> "uses" [errorhandlers] -[errorhandlers] --> "uses" [ui] -[parser] --> "uses" [travelactivitytype] -folder "omni.txt" as folder -folder .. [storage] - +@startuml +'https://plantuml.com/component-diagram + + + +Actor User as user + +user ..> [omnitravel] + +[omnitravel] --> "passes data"[parser] +[omnitravel] --> "Load/save"[storage] +[omnitravel] --> "uses" [ui] +[parser] --> "uses" [ui] +[parser] --> "uses" [exchangerateapi] +[parser] --> "uses" [errorhandlers] +[storage] --> "uses" [travelactivitytype] +[travelactivitytype] --> "uses" [ui] +[travelactivitytype] --> "uses" [errorhandlers] +[errorhandlers] --> "uses" [ui] +[parser] --> "uses" [travelactivitytype] +folder "omni.txt" as folder +folder .. [storage] + @enduml \ No newline at end of file diff --git a/docs/team/Errorhandler.puml b/docs/plantUML diagrams/Errorhandler.puml similarity index 91% rename from docs/team/Errorhandler.puml rename to docs/plantUML diagrams/Errorhandler.puml index ebf38c48cd..91ff8bb048 100644 --- a/docs/team/Errorhandler.puml +++ b/docs/plantUML diagrams/Errorhandler.puml @@ -1,30 +1,30 @@ -@startuml -'https://plantuml.com/class-diagram -skinparam packageStyle rectangle -hide class members -package errorhandlers{ -class CheckParameters -class OmniException -class Exception -} - -package travelactivitytypes{ -} - -package parser{ -} - -package ui{ -} - - - - -OmniException --|> Exception -CheckParameters ..> OmniException -CheckParameters --> ui -parser --> CheckParameters -travelactivitytypes --> CheckParameters - - +@startuml +'https://plantuml.com/class-diagram +skinparam packageStyle rectangle +hide class members +package errorhandlers{ +class CheckParameters +class OmniException +class Exception +} + +package travelactivitytypes{ +} + +package parser{ +} + +package ui{ +} + + + + +OmniException --|> Exception +CheckParameters ..> OmniException +CheckParameters --> ui +parser --> CheckParameters +travelactivitytypes --> CheckParameters + + @enduml \ No newline at end of file diff --git a/docs/team/FileSaveSequence.puml b/docs/plantUML diagrams/FileSaveSequence.puml similarity index 97% rename from docs/team/FileSaveSequence.puml rename to docs/plantUML diagrams/FileSaveSequence.puml index 27f0508933..672b23a0ff 100644 --- a/docs/team/FileSaveSequence.puml +++ b/docs/plantUML diagrams/FileSaveSequence.puml @@ -1,61 +1,61 @@ -@startuml -actor User -participant "readFile()" as readFile -participant "loadFileContents(TravelActivityList list)" as loadFileContents -participant "accommodation:Accommodation" as Accommodation -participant "food:Food" as Food -participant "landmark:Landmark" as Landmark -participant "list:TravelActivityList" as TravelActivityList -participant "SetActivityStatus" as SetActivityStatus -participant "s:Scanner" as Scanner - -User -> readFile: readFile() -activate readFile -readFile -> loadFileContents: loadFileContents(list) -activate loadFileContents - -loop scanner -loadFileContents -> Scanner: hasNext() -activate Scanner -Scanner --> loadFileContents: next -deactivate Scanner - alt Accomodation - loadFileContents -> Accommodation: list.addTravelActivity(accommodation) - activate Accommodation - Accommodation -> TravelActivityList: list.addTravelActivity(accommodation) - activate TravelActivityList - TravelActivityList --> Accommodation: added activity - deactivate TravelActivityList - Accommodation -> SetActivityStatus: setActivityStatus() - activate SetActivityStatus - SetActivityStatus --> Accommodation: Status handled - deactivate SetActivityStatus - else Food - loadFileContents -> Food: list.addTravelActivity(food) - activate Food - Food -> TravelActivityList: list.addTravelActivity(food) - activate TravelActivityList - TravelActivityList --> Food: added activity - deactivate TravelActivityList - Food -> SetActivityStatus: setActivityStatus() - activate SetActivityStatus - SetActivityStatus --> Food: Status handled - deactivate SetActivityStatus - else Landmark - loadFileContents -> Landmark: list.addTravelActivity(landmark) - activate Landmark - Landmark -> TravelActivityList: list.addTravelActivity(landmark) - activate TravelActivityList - TravelActivityList --> Landmark: added activity - deactivate TravelActivityList - Landmark -> SetActivityStatus: setActivityStatus() - activate SetActivityStatus - SetActivityStatus --> Landmark: Status handled - deactivate SetActivityStatus - end -end -deactivate TravelActivityList -deactivate loadFileContents -deactivate readFile - +@startuml +actor User +participant "readFile()" as readFile +participant "loadFileContents(TravelActivityList list)" as loadFileContents +participant "accommodation:Accommodation" as Accommodation +participant "food:Food" as Food +participant "landmark:Landmark" as Landmark +participant "list:TravelActivityList" as TravelActivityList +participant "SetActivityStatus" as SetActivityStatus +participant "s:Scanner" as Scanner + +User -> readFile: readFile() +activate readFile +readFile -> loadFileContents: loadFileContents(list) +activate loadFileContents + +loop scanner +loadFileContents -> Scanner: hasNext() +activate Scanner +Scanner --> loadFileContents: next +deactivate Scanner + alt Accomodation + loadFileContents -> Accommodation: list.addTravelActivity(accommodation) + activate Accommodation + Accommodation -> TravelActivityList: list.addTravelActivity(accommodation) + activate TravelActivityList + TravelActivityList --> Accommodation: added activity + deactivate TravelActivityList + Accommodation -> SetActivityStatus: setActivityStatus() + activate SetActivityStatus + SetActivityStatus --> Accommodation: Status handled + deactivate SetActivityStatus + else Food + loadFileContents -> Food: list.addTravelActivity(food) + activate Food + Food -> TravelActivityList: list.addTravelActivity(food) + activate TravelActivityList + TravelActivityList --> Food: added activity + deactivate TravelActivityList + Food -> SetActivityStatus: setActivityStatus() + activate SetActivityStatus + SetActivityStatus --> Food: Status handled + deactivate SetActivityStatus + else Landmark + loadFileContents -> Landmark: list.addTravelActivity(landmark) + activate Landmark + Landmark -> TravelActivityList: list.addTravelActivity(landmark) + activate TravelActivityList + TravelActivityList --> Landmark: added activity + deactivate TravelActivityList + Landmark -> SetActivityStatus: setActivityStatus() + activate SetActivityStatus + SetActivityStatus --> Landmark: Status handled + deactivate SetActivityStatus + end +end +deactivate TravelActivityList +deactivate loadFileContents +deactivate readFile + @enduml \ No newline at end of file diff --git a/docs/team/FileSaveUML.puml b/docs/plantUML diagrams/FileSaveUML.puml similarity index 96% rename from docs/team/FileSaveUML.puml rename to docs/plantUML diagrams/FileSaveUML.puml index b8f3a3e0f4..1a8296001e 100644 --- a/docs/team/FileSaveUML.puml +++ b/docs/plantUML diagrams/FileSaveUML.puml @@ -1,30 +1,30 @@ -@startuml -skinparam classAttributeIconSize 0 -class User -class FileSave { - + readFile(): void - - loadFileContents(list: TravelActivityList): void - - initialiseActivity(type: String, description: String, date: LocalDate, duration: String, tag: String, expense: String): TravelActivity - - saveActivityList(list: TravelActivityList): void - - readFile(list: TravelActivityList): void -} -class TravelActivityList { - - travelActivities: List - + addTravelActivity(activity: TravelActivity): void - + getTravelActivities(): List -} -class Scanner -class Accommodation -class Food -class Landmark -class SetActivityStatus - -User --> "1" FileSave: readFile() -FileSave --> "1" TravelActivityList: loadFileContents(list) -FileSave --> "1" Scanner: hasNext() -FileSave --> "*" Accommodation: initialiseActivity() -FileSave --> "*" Food: initialiseActivity() -FileSave --> "*" Landmark: initialiseActivity() -FileSave --> "*" SetActivityStatus: setActivityStatus() - +@startuml +skinparam classAttributeIconSize 0 +class User +class FileSave { + + readFile(): void + - loadFileContents(list: TravelActivityList): void + - initialiseActivity(type: String, description: String, date: LocalDate, duration: String, tag: String, expense: String): TravelActivity + - saveActivityList(list: TravelActivityList): void + - readFile(list: TravelActivityList): void +} +class TravelActivityList { + - travelActivities: List + + addTravelActivity(activity: TravelActivity): void + + getTravelActivities(): List +} +class Scanner +class Accommodation +class Food +class Landmark +class SetActivityStatus + +User --> "1" FileSave: readFile() +FileSave --> "1" TravelActivityList: loadFileContents(list) +FileSave --> "1" Scanner: hasNext() +FileSave --> "*" Accommodation: initialiseActivity() +FileSave --> "*" Food: initialiseActivity() +FileSave --> "*" Landmark: initialiseActivity() +FileSave --> "*" SetActivityStatus: setActivityStatus() + @enduml \ No newline at end of file diff --git a/docs/team/Overview.puml b/docs/plantUML diagrams/Overview.puml similarity index 100% rename from docs/team/Overview.puml rename to docs/plantUML diagrams/Overview.puml diff --git a/docs/team/TagSequenceDiagram.puml b/docs/plantUML diagrams/TagSequenceDiagram.puml similarity index 96% rename from docs/team/TagSequenceDiagram.puml rename to docs/plantUML diagrams/TagSequenceDiagram.puml index 64de501121..c47a14fa02 100644 --- a/docs/team/TagSequenceDiagram.puml +++ b/docs/plantUML diagrams/TagSequenceDiagram.puml @@ -1,25 +1,25 @@ -@startuml -'https://plantuml.com/sequence-diagram - -actor User - -participant "tagCommand(line: String, list: TravelActivityList)" as tagCommandMethod -participant "list: TravelActivityList" as TravelActivityListInstance -participant "OmniExceptionInstance: OmniException" as OmniExceptionInstance - -User -> tagCommandMethod: tagCommand(line, list) -activate tagCommandMethod - -tagCommandMethod -> tagCommandMethod: line.split(" ") -alt command.length == 3 && isNumeric(command[1]) - tagCommandMethod -> tagCommandMethod: int listNumber = Integer.parseInt(command[1]) - tagCommandMethod -> tagCommandMethod: String tag = command[2] - tagCommandMethod -> TravelActivityListInstance: tagActivity(listNumber, tag) -else command.length == 2 - tagCommandMethod -> OmniExceptionInstance: OmniException("Please specify a tag name") -else - tagCommandMethod -> OmniExceptionInstance: OmniException("Please specify which task to tag") -end - -deactivate tagCommandMethod +@startuml +'https://plantuml.com/sequence-diagram + +actor User + +participant "tagCommand(line: String, list: TravelActivityList)" as tagCommandMethod +participant "list: TravelActivityList" as TravelActivityListInstance +participant "OmniExceptionInstance: OmniException" as OmniExceptionInstance + +User -> tagCommandMethod: tagCommand(line, list) +activate tagCommandMethod + +tagCommandMethod -> tagCommandMethod: line.split(" ") +alt command.length == 3 && isNumeric(command[1]) + tagCommandMethod -> tagCommandMethod: int listNumber = Integer.parseInt(command[1]) + tagCommandMethod -> tagCommandMethod: String tag = command[2] + tagCommandMethod -> TravelActivityListInstance: tagActivity(listNumber, tag) +else command.length == 2 + tagCommandMethod -> OmniExceptionInstance: OmniException("Please specify a tag name") +else + tagCommandMethod -> OmniExceptionInstance: OmniException("Please specify which task to tag") +end + +deactivate tagCommandMethod @enduml \ No newline at end of file diff --git a/docs/team/TravelActivityTypeClassDiagram.puml b/docs/plantUML diagrams/TravelActivityTypeClassDiagram.puml similarity index 93% rename from docs/team/TravelActivityTypeClassDiagram.puml rename to docs/plantUML diagrams/TravelActivityTypeClassDiagram.puml index 5bd67d2d55..cdbf84f63f 100644 --- a/docs/team/TravelActivityTypeClassDiagram.puml +++ b/docs/plantUML diagrams/TravelActivityTypeClassDiagram.puml @@ -1,25 +1,25 @@ -@startuml -'https://plantuml.com/class-diagram -skinparam packageStyle rectangle -hide class members -package travelactivitytype{ -class TravelActivity -class Food -class Landmark -class Accommodation -class TravelActivityList -} -Food --|> TravelActivity -Landmark --|> TravelActivity -Accommodation --|> TravelActivity -TravelActivityList --> "*" TravelActivity -TravelActivityList --> ui -parser --> TravelActivityList -package ui{ - -} - -package parser{ - -} +@startuml +'https://plantuml.com/class-diagram +skinparam packageStyle rectangle +hide class members +package travelactivitytype{ +class TravelActivity +class Food +class Landmark +class Accommodation +class TravelActivityList +} +Food --|> TravelActivity +Landmark --|> TravelActivity +Accommodation --|> TravelActivity +TravelActivityList --> "*" TravelActivity +TravelActivityList --> ui +parser --> TravelActivityList +package ui{ + +} + +package parser{ + +} @enduml \ No newline at end of file diff --git a/docs/team/UpdateFeatureClassDiagram.puml b/docs/plantUML diagrams/UpdateFeatureClassDiagram.puml similarity index 95% rename from docs/team/UpdateFeatureClassDiagram.puml rename to docs/plantUML diagrams/UpdateFeatureClassDiagram.puml index cd0ad4d7ed..b4cd5c80e4 100644 --- a/docs/team/UpdateFeatureClassDiagram.puml +++ b/docs/plantUML diagrams/UpdateFeatureClassDiagram.puml @@ -1,32 +1,32 @@ -@startuml -'https://plantuml.com/class-diagram -skinparam classAttributeIconSize 0 -class OmniTravel{ --invokeCommand(command: String[], line: String, list: TravelActivityList): void -} - -class Parser{ -+updateCommand(line: String, list: TravelActivityList): void -} -class CheckParameters{ -+updateExceptions(command: String[], line: String): void -+containsWords(input String): void -} -class TravelActivityList{ -+updateTravelActivity(travelActivityNumber: int, date: LocalDate, duration: String, tag: String): void -} -class TravelActivity{ -+setDate(date: LocalDate): void -+setDuration(duration: String): void -+setTag(tag: String): void -} -class Ui{ -+printLine(): void -} -OmniTravel ..> Ui -OmniTravel ..> Parser -Parser --> TravelActivityList -TravelActivityList --> "*"TravelActivity -TravelActivityList ..> CheckParameters - +@startuml +'https://plantuml.com/class-diagram +skinparam classAttributeIconSize 0 +class OmniTravel{ +-invokeCommand(command: String[], line: String, list: TravelActivityList): void +} + +class Parser{ ++updateCommand(line: String, list: TravelActivityList): void +} +class CheckParameters{ ++updateExceptions(command: String[], line: String): void ++containsWords(input String): void +} +class TravelActivityList{ ++updateTravelActivity(travelActivityNumber: int, date: LocalDate, duration: String, tag: String): void +} +class TravelActivity{ ++setDate(date: LocalDate): void ++setDuration(duration: String): void ++setTag(tag: String): void +} +class Ui{ ++printLine(): void +} +OmniTravel ..> Ui +OmniTravel ..> Parser +Parser --> TravelActivityList +TravelActivityList --> "*"TravelActivity +TravelActivityList ..> CheckParameters + @enduml \ No newline at end of file diff --git a/docs/team/UpdateSequenceDiagram.puml b/docs/plantUML diagrams/UpdateSequenceDiagram.puml similarity index 100% rename from docs/team/UpdateSequenceDiagram.puml rename to docs/plantUML diagrams/UpdateSequenceDiagram.puml diff --git a/docs/lookupFunctions.puml b/docs/plantUML diagrams/lookupFunctions.puml similarity index 97% rename from docs/lookupFunctions.puml rename to docs/plantUML diagrams/lookupFunctions.puml index fd30efd093..f02c15358a 100644 --- a/docs/lookupFunctions.puml +++ b/docs/plantUML diagrams/lookupFunctions.puml @@ -1,67 +1,67 @@ -@startuml -alt first word of user command is "find" - OmniTravel -> Parser : findCommand() - Parser -> TravelActivityList : searchKeyword() - loop size of travelActivities ArrayList - alt activity description matches the keyword user inputted - TravelActivityList -> TravelActivityList : foundCounter += 1 - TravelActivityList -> System.out : println("Here are what you are looking for:") - TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); - Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) - alt Activity has a tag - Ui -> System.out : print(" (" + activity.getTag() + ")") - - else activity have no tag - Ui -> System.out : print(" (" + activity.getExpense() + ")") - end - Ui -> System.out : println() - end - end - alt no activity description matches the keyword user inputted - TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") - end -end - -alt first word of user command is "findtag" - OmniTravel -> Parser : findTagCommand() - Parser -> TravelActivityList : findTag() - loop size of travelActivities ArrayList - alt activity tag matches the keyword user inputted - TravelActivityList -> TravelActivityList : foundCounter += 1 - TravelActivityList -> System.out : println("Here are what you are looking for:") - TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); - Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) - alt Activity has a tag - Ui -> System.out : print(" (" + activity.getTag() + ")") - else activity have no tag - Ui -> System.out : print(" (" + activity.getExpense() + ")") - end - Ui -> System.out : println() - end - end - alt no activity tag matches the keyword user inputted - TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") - end -end -alt first word of user command is "findtype" - OmniTravel -> Parser : findTypeCommand() - Parser -> TravelActivityList : findType() - loop size of travelActivities ArrayList - alt activity tag matches the keyword user inputted - TravelActivityList -> TravelActivityList : foundCounter += 1 - TravelActivityList -> System.out : println("Here are what you are looking for:") - TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); - Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) - alt Activity has a tag - Ui -> System.out : print(" (" + activity.getTag() + ")") - else activity have no tag - Ui -> System.out : print(" (" + activity.getExpense() + ")") - end - Ui -> System.out : println() - end - end - alt no activity type matches the keyword user inputted - TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") - end -end +@startuml +alt first word of user command is "find" + OmniTravel -> Parser : findCommand() + Parser -> TravelActivityList : searchKeyword() + loop size of travelActivities ArrayList + alt activity description matches the keyword user inputted + TravelActivityList -> TravelActivityList : foundCounter += 1 + TravelActivityList -> System.out : println("Here are what you are looking for:") + TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); + Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) + alt Activity has a tag + Ui -> System.out : print(" (" + activity.getTag() + ")") + + else activity have no tag + Ui -> System.out : print(" (" + activity.getExpense() + ")") + end + Ui -> System.out : println() + end + end + alt no activity description matches the keyword user inputted + TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") + end +end + +alt first word of user command is "findtag" + OmniTravel -> Parser : findTagCommand() + Parser -> TravelActivityList : findTag() + loop size of travelActivities ArrayList + alt activity tag matches the keyword user inputted + TravelActivityList -> TravelActivityList : foundCounter += 1 + TravelActivityList -> System.out : println("Here are what you are looking for:") + TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); + Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) + alt Activity has a tag + Ui -> System.out : print(" (" + activity.getTag() + ")") + else activity have no tag + Ui -> System.out : print(" (" + activity.getExpense() + ")") + end + Ui -> System.out : println() + end + end + alt no activity tag matches the keyword user inputted + TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") + end +end +alt first word of user command is "findtype" + OmniTravel -> Parser : findTypeCommand() + Parser -> TravelActivityList : findType() + loop size of travelActivities ArrayList + alt activity tag matches the keyword user inputted + TravelActivityList -> TravelActivityList : foundCounter += 1 + TravelActivityList -> System.out : println("Here are what you are looking for:") + TravelActivityList -> Ui : printActivity(travelActivity, foundCounter); + Ui -> System.out : print(checked + " " + activityIndex + ". " + activity) + alt Activity has a tag + Ui -> System.out : print(" (" + activity.getTag() + ")") + else activity have no tag + Ui -> System.out : print(" (" + activity.getExpense() + ")") + end + Ui -> System.out : println() + end + end + alt no activity type matches the keyword user inputted + TravelActivityList -> System.out : println("Sorry I could not find what you are looking for.") + end +end @enduml \ No newline at end of file diff --git a/docs/totalexpense.puml b/docs/plantUML diagrams/totalexpense.puml similarity index 95% rename from docs/totalexpense.puml rename to docs/plantUML diagrams/totalexpense.puml index 29047533d5..9c3a482b38 100644 --- a/docs/totalexpense.puml +++ b/docs/plantUML diagrams/totalexpense.puml @@ -1,20 +1,20 @@ -@startuml -'https://plantuml.com/sequence-diagram - -autonumber -actor User -User -> OmniTravel : "totalexpense /type Food" -OmniTravel -> Parser : totalExpenseCommand(line, list) - Parser -> TravelActivityList : totalExpense(type) - loop size of travelActivities ArrayList - opt activity type matches the type the user inputed - TravelActivityList -> TravelActivity: getExpense() - TravelActivity --> TravelActivityList: - TravelActivityList -> TravelActivityList: total += expense - - end - end -TravelActivityList --> Parser -Parser --> OmniTravel -OmniTravel --> User +@startuml +'https://plantuml.com/sequence-diagram + +autonumber +actor User +User -> OmniTravel : "totalexpense /type Food" +OmniTravel -> Parser : totalExpenseCommand(line, list) + Parser -> TravelActivityList : totalExpense(type) + loop size of travelActivities ArrayList + opt activity type matches the type the user inputed + TravelActivityList -> TravelActivity: getExpense() + TravelActivity --> TravelActivityList: + TravelActivityList -> TravelActivityList: total += expense + + end + end +TravelActivityList --> Parser +Parser --> OmniTravel +OmniTravel --> User @enduml \ No newline at end of file diff --git a/docs/team/daryltay415.md b/docs/team/daryltay415.md index c751fdd351..99ce5b9a7c 100644 --- a/docs/team/daryltay415.md +++ b/docs/team/daryltay415.md @@ -1,43 +1,46 @@ -# Daryl Tay Chin Kian - Project Portfolio Page - -## Project: OmniTravel - -OmniTravel is a command line interface application used for tracking and planning travel activities. -It is able to convert currencies as well as set expenses for each travel activities. - -### Summary of Contributions -Given below are all the contributions I have made to this project. - -* New Feature: Added a update command to update travel activities - * What it does: Allows the user to update the existing travel activity with a new date, duration - and tag. - * Justification: Users might have changes in their plans and this feature will make it much easier - for users to edit their plans. - * Highlights: This enhancement does affect some existing commands. -* New Feature: Added a exchange currency command to change from one currency to another - * What it does: Allows the user to convert an amount of a local currency to a foreign currency. - * Justification: This feature allows the user to check how much local currency they require to convert - to the foreign currency. It makes it more convenient for them to plan how much expenses they require - for certain activities. - * Highlights: It required some in-depth analysis to ensure the exceptions were handled well. - The implementation was also challenging as it was my first time using an API and the guide - given by the third party does not explain much on using the API. - * Credits: Current exchange API: insert link here - -* Code contributed: [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=daryltay415&breakdown=true&sort=groupTitle%20dsc&sortWithin=title&since=2024-02-23&timeframe=commit&mergegroup=&groupSelect=groupByRepos&checkedFileTypes=docs~functional-code~test-code~other) -* Project management: - * Managed releases v1.0 - v2.0 (2 releases) on GitHub -* Enhancements to existing features: - * Added ability to add dates and duration to the `add` feature [#81](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/81) -* Documentation: - * User Guide: - * Added documentation for the features `add`,`update`,`list`, `listtags`, `change` [#110](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/110), [#195](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/195) - * Developer Guide: - * Added implementation details of the `update` feature [#94](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/94) - * Added class diagram for overview of all classes [#126](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/126) - * Added manual testing details [#203](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/203) -* Community: - * Reported bugs and suggestions for other teams in the class (examples [1](https://github.com/nus-cs2113-AY2324S2/tp/pull/45/files), - [2](https://github.com/nus-cs2113-AY2324S2/tp/pull/85/files)) -* Tools: - * Integrated a third part API to the project [#195](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/195) \ No newline at end of file +# Daryl Tay Chin Kian - Project Portfolio Page + +## Project: OmniTravel + +OmniTravel is a command line interface application used for tracking and planning travel activities. +It is able to convert currencies as well as set expenses for each travel activities. + +### Summary of Contributions +Given below are all the contributions I have made to this project. + +* New Feature: Added a update command to update travel activities + * What it does: Allows the user to update the existing travel activity with a new date, duration + and tag. + * Justification: Users might have changes in their plans and this feature will make it much easier + for users to edit their plans. + * Highlights: This enhancement does affect some existing commands. +* New Feature: Added a exchange currency command to change from one currency to another + * What it does: Allows the user to convert an amount of a local currency to a foreign currency. + * Justification: This feature allows the user to check how much local currency they require to convert + to the foreign currency. It makes it more convenient for them to plan how much expenses they require + for certain activities. + * Highlights: It required some in-depth analysis to ensure the exceptions were handled well. + The implementation was also challenging as it was my first time using an API and the guide + given by the third party does not explain much on using the API. + * Credits: Current exchange API: [link](https://github.com/fawazahmed0/exchange-api/blob/main/LICENSE) + +* Code contributed: [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=daryltay415&breakdown=true&sort=groupTitle%20dsc&sortWithin=title&since=2024-02-23&timeframe=commit&mergegroup=&groupSelect=groupByRepos&checkedFileTypes=docs~functional-code~test-code~other) +* Project management: + * Released issues in v1.0 on GitHub + * Managed releases v1.0 - v2.0 (2 releases) on GitHub +* Enhancements to existing features: + * Added ability to add dates and duration to the `add` feature [#81](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/81) +* Documentation: + * User Guide: + * Added documentation for the features `add`,`update`,`list`, `listtags`, `change` [#110](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/110), [#195](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/195) + * Developer Guide: + * Added implementation details of the `update` feature [#94](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/94) + * Added class diagram for overview of all classes [#228](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/228) + * Added details about the main components of the system [#228](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/228) + * Added manual testing details [#203](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/203) +* Community: + * Reported bugs and suggestions for other teams in the class (examples [1](https://github.com/nus-cs2113-AY2324S2/tp/pull/45/files#r1550908455), + [2](https://github.com/nus-cs2113-AY2324S2/tp/pull/85/files#r1550881947)) +* Tools: + * Integrated a third part API to the project [#195](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/195) +* Other contributions: Fixing, debugging and testing of code. [#193](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/193) \ No newline at end of file From 498d3b653b0c4850e4c104d416206fec46c08f1e Mon Sep 17 00:00:00 2001 From: daryltay415 <13zidane@gmail.com> Date: Sun, 14 Apr 2024 16:30:07 +0800 Subject: [PATCH 3/5] Fix bugs --- docs/UserGuide.md | 4 +- omni.txt | 1 + .../errorhandlers/CheckParameters.java | 26 +++++----- .../omnitravel/omnitravel/OmniTravel.java | 4 +- .../java/seedu/omnitravel/parser/Parser.java | 49 ++++++++++--------- .../TravelActivityList.java | 24 +++++++-- src/main/java/seedu/omnitravel/ui/Ui.java | 5 +- 7 files changed, 68 insertions(+), 45 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index afd40a0968..5a4fa3df47 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -58,7 +58,7 @@ ____________________________________________________________ > 📒 Notes about the command format : > * The words that are in `UPPER_CASE` represents the parameters that the users are required to input > e.g. `delete INDEX`, `INDEX` is a parameter which can be used as `delete 1`. -> * Commands such as `help`, `list` and `bye` do not require additional parameters. Hence, any extra parameters will be ignored. +> * Commands such as `help` and `bye` do not require additional parameters. Hence, any extra parameters will be ignored. > e.g. `help 123` will just be intepreted as `help`. > * Words that are in square brackets such as `[/tag TAG]` indicates that it is > optional to include in the command. @@ -341,6 +341,7 @@ their travel activities. Format: `tag INDEX TAGNAME` * The `INDEX` must be a valid activity index. +* There must not be any trailing spaces in `INDEX`. Example of usage: * `tag 1 activity 1` @@ -359,6 +360,7 @@ Removes a tag from an existing travel activity. Format: `untag INDEX` * The `INDEX` must be a valid activity index. +* * There must not be any trailing spaces in `INDEX`. Example of usage: * `untag 1 ` diff --git a/omni.txt b/omni.txt index e69de29bb2..15c158fac7 100644 --- a/omni.txt +++ b/omni.txt @@ -0,0 +1 @@ +general / 0 / go to paris / 2024-12-12 / 2 hours / / diff --git a/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java b/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java index 0e2ebcf765..5f3d990523 100644 --- a/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java +++ b/src/main/java/seedu/omnitravel/errorhandlers/CheckParameters.java @@ -34,9 +34,10 @@ public static void addExceptions(String[] input, String commandType, String line throw new OmniException("The tag cannot be empty!"); } else if (input.length < 3 || input[2].contains("/tag") || !command[1].contains("date") || !command[2].contains("duration")){ - throw new OmniException("Please check that your add command is in this format: add DESCRIPTION " + - "/date YYYY-MM-DD /duration DURATION" - + " or add DESCRIPTION /date YYYY-MM-DD /duration DURATION /tag TAG"); + throw new OmniException("Please check that your " + commandType + " command is in this format: \n" + + commandType + " DESCRIPTION " + + "/date YYYY-MM-DD /duration DURATION\n" + + "or " + commandType + " DESCRIPTION /date YYYY-MM-DD /duration DURATION /tag TAG"); } } @@ -49,8 +50,9 @@ public static void addExceptions(String[] input, String commandType, String line */ public static void updateExceptions(String[] command, String line) throws OmniException { String[] lineSplit = line.split("/"); - if (command.length >= 4 && (command[1].isBlank() || !isNumeric(command[1]))) { - throw new OmniException("The update index cannot be empty or non numerical!"); + if (command.length >= 4 && (command[1].isBlank() || !isNumeric(command[1].trim()))) { + throw new OmniException("The update index cannot be empty or non numerical!\n" + + "It must be a single number"); } else if (command.length >= 4 && command[2].isBlank()) { throw new OmniException("The date cannot be empty!"); } else if (command.length >= 4 && command[3].isBlank()) { @@ -59,9 +61,9 @@ public static void updateExceptions(String[] command, String line) throws OmniEx throw new OmniException("The tag cannot be empty!"); } else if (command.length < 4 || command[3].contains("/tag") || !lineSplit[1].contains("date") || !lineSplit[2].contains("duration")) { - throw new OmniException("Please check that your update command is in this format: update INDEX " + - "/date YYYY-MM-DD /duration DURATION" - + " or update INDEX /date YYYY-MM-DD /duration DURATION /tag TAG"); + throw new OmniException("Please check that your update command is in this format: \nupdate INDEX " + + "/date YYYY-MM-DD /duration DURATION\n" + + "or update INDEX /date YYYY-MM-DD /duration DURATION /tag TAG"); } } @@ -86,7 +88,7 @@ public static void listExceptions(String[] command, String[] input, String line) // command length greater than 4 boolean case4 = command.length > 4; if (case1 || case2 || case3 || case4) { - throw new OmniException("Please check that your list command is in this format:" + + throw new OmniException("Please check that your list command is in this format:\n" + "list [/date YYYY-MM-DD] [/sort]"); } } @@ -109,7 +111,7 @@ public static void containsWords(String input) throws OmniException{ } } } - throw new OmniException("Your duration is invalid. Please input in terms of \"1 " + + throw new OmniException("Your duration is invalid. Please input in terms of \n\"1 " + "day/s, week/s, month/s, year/s, hour/s, minutue/s or second/s\""); } @@ -136,7 +138,7 @@ public static boolean isNumeric(String str) { */ public static boolean isValidExpense(String str) throws OmniException{ if(isNumeric(str)){ - int expense = Integer.parseInt(str); + float expense = Float.parseFloat(str); if(expense <= 0){ throw new OmniException("Your expense cannot be less than $0"); } @@ -162,7 +164,7 @@ public static void checkCurrencyParameters(String[] command, String line) throws } else if(command.length == 4 && command[2].trim().equalsIgnoreCase(command[3].trim())){ throw new OmniException("The 2 currencies cannot be the same!"); } else if(command.length < 4 || !lineSplit[1].contains("from")){ - throw new OmniException("Please check that your format is correct:" + + throw new OmniException("Please check that your format is correct:\n" + "change AMOUNT /from CURRENCY /to CURRENCY"); } diff --git a/src/main/java/seedu/omnitravel/omnitravel/OmniTravel.java b/src/main/java/seedu/omnitravel/omnitravel/OmniTravel.java index de1adb4d8f..c68736a125 100644 --- a/src/main/java/seedu/omnitravel/omnitravel/OmniTravel.java +++ b/src/main/java/seedu/omnitravel/omnitravel/OmniTravel.java @@ -105,10 +105,10 @@ private static void invokeCommand(String[] command, Parser.deleteCommand(command, list, line); break; case "check": - Parser.checkCommand(command, list); + Parser.checkCommand(command, list, line); break; case "uncheck": - Parser.uncheckCommand(command, list); + Parser.uncheckCommand(command, list, line); break; case "find": Parser.findCommand(line, list); diff --git a/src/main/java/seedu/omnitravel/parser/Parser.java b/src/main/java/seedu/omnitravel/parser/Parser.java index b0d76b3615..4130476ae9 100644 --- a/src/main/java/seedu/omnitravel/parser/Parser.java +++ b/src/main/java/seedu/omnitravel/parser/Parser.java @@ -118,7 +118,7 @@ public static void addCommand(String line, TravelActivityList list) throws OmniE String[] command = line.split("/date | /duration | /tag "); //logger.log(Level.INFO, command[0] + " // " + command[1]); CheckParameters.addExceptions(command, "add", line); - String description = line.substring(4, line.indexOf("/date")); + String description = line.substring(4, line.indexOf("/date")).trim(); LocalDate date = LocalDate.parse(command[1]); if(date.isBefore(LocalDate.now())){ throw new OmniException("Please input a future date."); @@ -144,15 +144,16 @@ public static void deleteCommand(String[] command, TravelActivityList list, Stri if(list.getNoOfTravelActivities() == 0){ throw new OmniException("The list is empty!"); } + String[] lineSplit = line.split("delete"); try { if (command.length < 2) { throw new OmniException("Please specify which activity index or description to delete"); } - int input = Integer.parseInt(command[1]); + int input = Integer.parseInt(lineSplit[1].trim()); list.removeTravelActivity(input); } catch (NumberFormatException e) { - int indexOfDescription = line.indexOf(command[1]); - String description = line.substring(indexOfDescription); + int indexOfDescription = line.indexOf(lineSplit[1]); + String description = line.substring(indexOfDescription).trim(); list.removeTravelActivity(description); } } @@ -165,9 +166,10 @@ public static void deleteCommand(String[] command, TravelActivityList list, Stri * @param list List of travel activities * @throws OmniException if command.length != 2 && command[1] is not numeric */ - public static void checkCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && CheckParameters.isNumeric(command[1])){ - int listNumber = Integer.parseInt(command[1]); + public static void checkCommand(String[] command, TravelActivityList list, String line) throws OmniException { + String[] lineSplit = line.split("check"); + if (command.length >= 2 && CheckParameters.isNumeric(lineSplit[1].trim())){ + int listNumber = Integer.parseInt(lineSplit[1].trim()); list.checkTravelActivity(listNumber); } else { throw new OmniException("Please specify which activity to check"); @@ -181,9 +183,10 @@ public static void checkCommand(String[] command, TravelActivityList list) throw * @param list List of travel activities * @throws OmniException if command.length != 2 && command[1] is not numeric */ - public static void uncheckCommand(String[] command, TravelActivityList list) throws OmniException { - if (command.length == 2 && CheckParameters.isNumeric(command[1])){ - int listNumber = Integer.parseInt(command[1]); + public static void uncheckCommand(String[] command, TravelActivityList list, String line) throws OmniException { + String[] lineSplit = line.split("uncheck"); + if (command.length == 2 && CheckParameters.isNumeric(command[1].trim())){ + int listNumber = Integer.parseInt(command[1].trim()); list.uncheckTravelActivity(listNumber); } else { @@ -207,8 +210,8 @@ public static void tagCommand(String line, TravelActivityList list) throws OmniE logger.log(Level.INFO, "Tagging command: " + line); String[] command = line.split(" "); - if (command.length >= 3 && CheckParameters.isNumeric(command[1])) { - int listNumber = Integer.parseInt(command[1]); + if (command.length >= 3 && CheckParameters.isNumeric(command[1].trim())) { + int listNumber = Integer.parseInt(command[1].trim()); // Extract tags starting from the third element onwards String[] tagArray = Arrays.copyOfRange(command, 2, command.length); // Join the tags into a single string @@ -238,8 +241,8 @@ public static void removeTagCommand(String[] command, TravelActivityList list) t logger.log(Level.INFO, "Remove tag command: " + Arrays.toString(command)); - if (command.length == 2 && CheckParameters.isNumeric(command[1])) { - int listNumber = Integer.parseInt(command[1]); + if (command.length == 2 && CheckParameters.isNumeric(command[1].trim())) { + int listNumber = Integer.parseInt(command[1].trim()); list.removeTag(listNumber); } else { @@ -265,7 +268,7 @@ public static void updateCommand(String line, TravelActivityList list) throws Om } String duration = command[3].trim(); CheckParameters.containsWords(duration); - list.updateTravelActivity(Integer.parseInt(command[1]), date, duration, + list.updateTravelActivity(Integer.parseInt(command[1].trim()), date, duration, tag); } @@ -288,7 +291,7 @@ public static void findTagCommand(String line, TravelActivityList list) throws O String exclusion = command[2].trim(); list.findTag(keyword, exclusion); } else { - throw new OmniException("Please check that your find tag command is in this format: " + + throw new OmniException("Please check that your find tag command is in this format:\n" + "findtag " + "or findtag /exclude "); } } @@ -313,7 +316,7 @@ public static void findTypeCommand(String line, TravelActivityList list) throws keyword = keyword.equalsIgnoreCase("general")? "TravelActivity":keyword; list.findType(keyword, exclusion); } else { - throw new OmniException("Please check that your find type command is in this format: + " + + throw new OmniException("Please check that your find type command is in this format:\n" + "findtype " + "or findtype /exclude "); } } @@ -335,7 +338,7 @@ public static void findCommand(String line, TravelActivityList list) throws Omni String exclusion = command[2].trim(); list.searchKeyword(keyword, exclusion); } else { - throw new OmniException("Please check that your find command is in this format: + " + + throw new OmniException("Please check that your find command is in this format:\n" + "find " + "or find /exclude "); } } @@ -356,8 +359,8 @@ public static void expenseCommand(String line, TravelActivityList list) throws O logger.log(Level.INFO, "Expense command: " + line); String[] command = line.split(" "); - if (command.length == 3 && CheckParameters.isNumeric(command[1])) { - int listNumber = Integer.parseInt(command[1]); + if (command.length == 3 && CheckParameters.isNumeric(command[1].trim())) { + int listNumber = Integer.parseInt(command[1].trim()); String expense = command[2]; list.expenseActivity(listNumber, expense); } else if (command.length == 2) { @@ -382,8 +385,8 @@ public static void removeExpenseCommand(String[] command, TravelActivityList lis logger.log(Level.INFO, "Remove expense command: " + Arrays.toString(command)); - if (command.length == 2 && CheckParameters.isNumeric(command[1])) { - int listNumber = Integer.parseInt(command[1]); + if (command.length == 2 && CheckParameters.isNumeric(command[1].trim())) { + int listNumber = Integer.parseInt(command[1].trim()); list.removeExpense(listNumber); } else { logger.log(Level.WARNING, "Invalid command format: " + Arrays.toString(command)); @@ -401,7 +404,7 @@ public static void removeExpenseCommand(String[] command, TravelActivityList lis */ public static void totalExpenseCommand(String line, TravelActivityList list) throws OmniException { String[] command = line.split("/type"); - if (command.length < 1 || command.length > 2) { + if ((command.length == 1 && line.contains("type")) || command.length > 2) { throw new OmniException("Please check your command is in the format totalexpense [/type TYPE]"); } if (command.length == 1) { diff --git a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java index 488077f966..85ed4c514a 100644 --- a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java +++ b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java @@ -188,10 +188,13 @@ public void searchKeyword (String activityName) { public void searchKeyword (String activityName, String exclusion) { int foundCounter = 0; + String lowerCaseActivityName = activityName.toLowerCase(); + String lowerCaseExclusion = exclusion.toLowerCase(); for (TravelActivity travelActivity : travelActivities) { assert !(foundCounter > travelActivities.size()) : "Error: There is more activities found than possible"; - if (travelActivity.getPlan().contains(activityName) && !travelActivity.getPlan().contains(exclusion) && - !travelActivity.getPlan().isEmpty()) { + if (travelActivity.getPlan().toLowerCase().contains(lowerCaseActivityName) + && !travelActivity.getPlan().toLowerCase().contains(lowerCaseExclusion) + && !travelActivity.getPlan().isEmpty()) { foundCounter += 1; if (foundCounter == 1) { System.out.println("Here are what you are looking for:"); @@ -289,6 +292,9 @@ public void removeTag(int taskNumber) throws OmniException { int indexOfTask = taskNumber - 1; TravelActivity taggedTask = travelActivities.get(indexOfTask); + if (taggedTask.getTag().isBlank()){ + throw new OmniException("Travel activity does not have a tag!"); + } taggedTask.removeTag(); System.out.println("Tag removed from the task:"); System.out.println(taggedTask); @@ -360,10 +366,11 @@ public void findTag(String tag){ public void findTag(String tag, String exclude){ int foundCounter = 0; + String lowerCaseExclude = exclude.toLowerCase(); for (TravelActivity travelActivity : travelActivities) { assert !(foundCounter > travelActivities.size()) : "Error: There is more activities found than possible"; if (travelActivity.getTag().contains(tag) && !travelActivity.getTag().isEmpty() && - !travelActivity.getPlan().contains(exclude)) { + !travelActivity.getPlan().toLowerCase().contains(lowerCaseExclude)) { foundCounter += 1; if (foundCounter == 1) { System.out.println("Here are what you are looking for:"); @@ -414,11 +421,12 @@ public void findType(String type, String exclude) { assert exclude != null && !exclude.isEmpty() : "Exclude parameter should not be null or empty"; logger.log(Level.INFO, "Finding type: " + type + ", excluding: " + exclude); - + String lowerCaseExclude = exclude.toLowerCase(); for (TravelActivity activity : travelActivities) { assert !(foundCounter > travelActivities.size()) : "Error: There are more activities found than possible"; - if (activity.getClass().getSimpleName().equalsIgnoreCase(type) && !activity.getPlan().contains(exclude)) { + if (activity.getClass().getSimpleName().equalsIgnoreCase(type) + && !activity.getPlan().toLowerCase().contains(lowerCaseExclude)) { foundCounter++; if (foundCounter == 1) { logger.log(Level.INFO, "Found matching activities:"); @@ -482,6 +490,9 @@ public void removeExpense(int taskNumber) throws OmniException { int indexOfTask = taskNumber - 1; TravelActivity task = travelActivities.get(indexOfTask); + if (task.getExpense().isBlank()){ + throw new OmniException("Travel activity does not have a expense!"); + } task.removeExpense(); System.out.println("Expense removed from the task:"); System.out.println(task); @@ -514,6 +525,9 @@ public void totalExpense(String type) throws OmniException { } } } + if(type.equalsIgnoreCase("travelactivity")){ + type = "General"; + } System.out.println("The total expense for " + type + " travel activities is: $" + tot); } diff --git a/src/main/java/seedu/omnitravel/ui/Ui.java b/src/main/java/seedu/omnitravel/ui/Ui.java index 67b903aea2..3a132063e5 100644 --- a/src/main/java/seedu/omnitravel/ui/Ui.java +++ b/src/main/java/seedu/omnitravel/ui/Ui.java @@ -40,7 +40,7 @@ public static void printBye(){ * Prints line */ public static void printLine(){ - System.out.println("____________________________________________________________"); + System.out.println("_______________________________________________________________________________"); } /** @@ -66,7 +66,8 @@ public static void printNoSuchElementException(NoSuchElementException exception) * @param exception The exception to be printed */ public static void printNumberTooLargeException(NumberFormatException exception) { - System.out.println("Warning! " + exception.getMessage() + " number too large!"); + System.out.println("Warning! " + exception.getMessage() + " number too large!\n" + + "or number format is wrong!"); printLine(); } From b10bc73c457dd2fb4fca152dcb8220777e551005 Mon Sep 17 00:00:00 2001 From: daryltay415 <13zidane@gmail.com> Date: Sun, 14 Apr 2024 16:34:24 +0800 Subject: [PATCH 4/5] Fix gradle --- src/test/java/seedu/omnitravel/OmniTravelTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 61c23b323b..dd8e2d2669 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -422,11 +422,11 @@ public void testGetList() throws OmniException { @Test public void testActivityCommand() throws OmniException { TravelActivityList list = new TravelActivityList(); - String expectedOutput4 = "____________________________________________________________" + + String expectedOutput4 = "_______________________________________________________________________________" + System.lineSeparator() + "I added a new accommodation" + System.lineSeparator() + "Accommodation: description :4 Oct 2024 :2 days (test)" + System.lineSeparator() + - "____________________________________________________________"; + "_______________________________________________________________________________"; Parser.activityCommand("accommodation description /date 2024-10-04 /duration 2 days /tag test", list); assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); } @@ -691,7 +691,7 @@ public void testCheckCommandMethod() throws OmniException{ list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"check", "1"}; - Parser.checkCommand(command, list); + Parser.checkCommand(command, list, "check 1"); } @Test @@ -700,7 +700,7 @@ public void testUncheckCommandMethod() throws OmniException{ list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"uncheck", "1"}; - Parser.uncheckCommand(command, list); + Parser.uncheckCommand(command, list, "uncheck 1"); } @Test From 34e4f54c4c81d9a85b8e7d8ceb5f1e2fb9e22203 Mon Sep 17 00:00:00 2001 From: daryltay415 <13zidane@gmail.com> Date: Sun, 14 Apr 2024 16:38:53 +0800 Subject: [PATCH 5/5] Update test Ui text --- text-ui-test/EXPECTED.TXT | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 9ae9090484..2a88ad6461 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,5 +1,5 @@ No existing database found! Creating a new save file for you! -____________________________________________________________ +_______________________________________________________________________________ ____ _ _ _ _____ ____ ____ _ _____ _ / _ \/ \__/|/ \ /|/ \/__ __\/ __\/ _ \/ \ |\/ __// \ | / \|| |\/||| |\ ||| | / \ | \/|| / \|| | //| \ | | @@ -7,8 +7,8 @@ ____________________________________________________________ \____/\_/ \|\_/ \|\_/ \_/ \_/\_\\_/ \|\__/ \____\\____/) Hello How may I assist you? -____________________________________________________________ -____________________________________________________________ +_______________________________________________________________________________ +_______________________________________________________________________________ Thank you for using Omnitravel We hope to see you again! Goodbye! -____________________________________________________________ +_______________________________________________________________________________