diff --git a/docs/ArchitectureDiagram.png b/docs/ArchitectureDiagram.png new file mode 100644 index 0000000000..49613c3d49 Binary files /dev/null and b/docs/ArchitectureDiagram.png differ diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 01cfb9f2f9..06ce2cc50d 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -1,6 +1,13 @@ # Developer Guide * [Acknowledgements](#acknowledgements) -* [Design & implementation](#design--implementation) +* [Design](#design) + * [Architecture](#architecture) + * [Storage component](#storage-component) + * [Parser component](#parser-component) + * [TravelActivityTypes component](#travelactivitytypes-component) + * [Ui component](#ui-component) + * [Errorhandlers component](#errorhandlers-component) +* [Implementation](#implementation) * [Save feature](#save-feature) * [Update feature](#update-feature) * [Total expense feature](#total-expense-feature) @@ -34,12 +41,80 @@ Source for currency exchange API: [link](https://github.com/fawazahmed0/exchange-api/blob/main/LICENSE) -## Design & implementation +## Design +### Architecture +![ArchitectureDiagram.png](ArchitectureDiagram.png) -### Overview -![Overview.png](Overview.png) -Given above is a overview of how each classes interact with one another in our software. +The architecture diagram above describes the high level design of the OmniTravel app. + +**Main components of the architecture** + +`omnitravel` which consists of the class `OmniTravel` has the responsibility of launching the app and shutting down. +* When the app launches, it initializes the other components in the app. +* When it shuts down, it will also shut down the other components. + +The main components of the system are as follows: +* `storage`: It reads data from the folder omni.txt and writes data to it. +* `parser`: It filters the commands and executes them. +* `travelactivitytypes`: It holds the data of the app in memory. +* `ui`: The UI of the app. +* `errorhandlers`: It handles all the exceptions and checks for any errors in the app. + +### Storage component +The Storage component only consists of one class `FileSave`. + +The storage component, +* saves the data of the different travel activity types, including their tags, expenses, type and +description. +* it listens to the `omnitravel` component to know when to save and load the file from omni.txt into the app. +* it retrieves travel activity objects from the `travelactivitytype` component to save. + +### Parser component +The parser component only consists of one class `Parser`. + +The parser component, +* handles all the command inputs by the user + and carries out the appropriate actions depending on the command given. +* uses the `ui` component to print responses to the user +* sends commands to the `exchangerateapi` and `travelactivitytype` components to execute. +* receives data from the `omnitravel` component. + + +### TravelActivityTypes component + +![TravelActivityTypeClassDiagram.png](TravelActivityTypeClassDiagram.png) +The TravelActivityTypes component consists of a few different classes: +* `Accommodation`: A subclass of travel activity related to accommodation +* `Food`: A subclass of travel activity related to food +* `Landmark`: A subclass of travel activity related to landmark +* `TravelActivtiy`: The parent class of `Accommodation`, `Food` and `Landmark` +* `TravelActivityList`: An array consisting of travel activity type objects + +The `TravelActivityTypes` component, +* stores all the travel activity type objects in an array. +* listens to the `parser` component for any commands to execute. + +### Ui component +The Ui component only consists of one class `Ui`. + +The Ui component, +* listens to the `omnitravel`, `parser` and `travelactivitytypes` component to print out +the responses to the user. +* contains all the responses to each of the user's input command +* takes in exceptions as parameters and prints out the error message. + +### Errorhandlers component +![Errorhandlers.png](Errorhandler.png) +The Errorhandler component consists of two classes `CheckParameters` and `OmniException`. +`OmniException` is a subclass of the parent class `Exception`. + +The Errorhandler component, +* checks the parameters of the commands given by the user. +* handles all the exceptions and errors in the app. +* keeps a reference to `ui` component to print error messages. + +## Implementation ### Save feature @@ -87,6 +162,9 @@ in the travel activity list. The `update` command calls the `Parser#updateComman Step 3. The method will then find the travel activity with the corresponding travel activity number in the `travelActivities` and then set the new date and duration of that travel activity. +The class diagram below shows the main relationship between the classes in the update feature: +![UpdateFeatureClassDiagrma.png](UpdateFeatureClassDiagram.png) + The sequence diagram below shows how an update operation goes through the parser component: ![img_1.png](img_1.png) diff --git a/docs/Errorhandler.png b/docs/Errorhandler.png new file mode 100644 index 0000000000..1bd4bd747f Binary files /dev/null and b/docs/Errorhandler.png differ diff --git a/docs/TravelActivityTypeClassDiagram.png b/docs/TravelActivityTypeClassDiagram.png new file mode 100644 index 0000000000..aaf3ad4ebe Binary files /dev/null and b/docs/TravelActivityTypeClassDiagram.png differ diff --git a/docs/UpdateFeatureClassDiagram.png b/docs/UpdateFeatureClassDiagram.png new file mode 100644 index 0000000000..28c9fdc2ea Binary files /dev/null and b/docs/UpdateFeatureClassDiagram.png differ diff --git a/docs/team/ArchitectureDiagram.puml b/docs/team/ArchitectureDiagram.puml new file mode 100644 index 0000000000..e4ef5327f9 --- /dev/null +++ b/docs/team/ArchitectureDiagram.puml @@ -0,0 +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] + +@enduml \ No newline at end of file diff --git a/docs/team/Errorhandler.puml b/docs/team/Errorhandler.puml new file mode 100644 index 0000000000..ebf38c48cd --- /dev/null +++ b/docs/team/Errorhandler.puml @@ -0,0 +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 + + +@enduml \ No newline at end of file diff --git a/docs/team/TravelActivityTypeClassDiagram.puml b/docs/team/TravelActivityTypeClassDiagram.puml new file mode 100644 index 0000000000..5bd67d2d55 --- /dev/null +++ b/docs/team/TravelActivityTypeClassDiagram.puml @@ -0,0 +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{ + +} +@enduml \ No newline at end of file diff --git a/docs/team/UpdateFeatureClassDiagram.puml b/docs/team/UpdateFeatureClassDiagram.puml new file mode 100644 index 0000000000..cd0ad4d7ed --- /dev/null +++ b/docs/team/UpdateFeatureClassDiagram.puml @@ -0,0 +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 + +@enduml \ No newline at end of file