Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2113-T18-4#183 from lckjosh/master
Browse files Browse the repository at this point in the history
Include more class diagrams
  • Loading branch information
lckjosh authored Nov 13, 2023
2 parents 5621d8d + 5eb5f1f commit 1014962
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 5 deletions.
38 changes: 33 additions & 5 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,31 @@ The bulk of the app's work is done by the following five components:
- **Storage Interaction with Data:**
- The Storage component access the Data to store/read to file.

Below is a simplified class diagram of the system:

<img src="images/SimpleClassDiagram.png" width="500" />

### UI Component

<img src="images/UiClassDiagram.png" width="500" />

**UI Component**
The `ui` packages consists of the `Ui` class and the `Messages` class.

The UI component prompts and reads commands from the user and sends the command to `Parser` package to be executed.
The UI component is also responsible for printing output to the user.
The `UI` component prompts and reads commands from the user.

The `UI` component is also responsible for printing output to the user.

**Data Component**
`TransactionList`, `Storage`, `Nuscents`, and `Command` use `Ui` to print output (including errors) to the user.

### Data Component

<img src="images/DataClassDiagram.png" width="500" />

The Data component stores the transaction data i.e., all `Transaction` objects in a `TransactionList` object.

Each `Transaction` object stores the information for an `Allowance` or an `Expense`.

**Command Component**
### Command Component

<img src="images/CommandClassDiagram.png" width="500" />

Expand All @@ -111,6 +120,25 @@ If it is not valid, an object of class `InvalidCommand` will be constructed. The
`InvalidCommand` class simply raises an exception that an invalid command has been entered, which will be shown
to the user.

### Parser component

<img src="images/ParserClassDiagram.png" width="500" />

The `Parser` component creates various `Command` and `Transaction` objects based on the user's input.
For example, if the user input is to add an expense, an `Expense` and `AddCommand` object will be created.

`Parser` also uses `ExpenseCategory`, `AllowanceCategory`, and `TransactionCategory` for creating expenses,
creating allowances, and filtering transactions respectively.

### Storage component

<img src="images/StorageClassDiagram.png" width="500" />

The `Storage` component reads/writes from/to the ArrayList in `TransactionList` depending on if the application is
starting or if a command has just been executed.

`Storage` also uses `Parser` to parse data from the storage file when the application starts up.

## **Implementation**

### `add` Transaction Feature
Expand Down
33 changes: 33 additions & 0 deletions docs/diagrams/ParserClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@startuml
!import style.puml
hide members
hide circle

enum ExpenseCategory <<enumeration>>
enum AllowanceCategory <<enumeration>>
interface TransactionCategory <<interface>>

abstract class Command {
+abstract void execute(TransactionList)
}


class Parser {
}

class Transaction {
}

Parser ..> Command : creates
Parser ..> Transaction : creates

Command ..> Transaction : uses

Parser ..> TransactionCategory : uses
Parser ..> AllowanceCategory : uses
Parser ..> ExpenseCategory : uses

ExpenseCategory ..|> TransactionCategory
AllowanceCategory ..|> TransactionCategory

@enduml
36 changes: 36 additions & 0 deletions docs/diagrams/SimpleClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@startuml
hide members
hide circle

class Transaction
class Expense
class Allowance
enum ExpenseCategory <<enumeration>> implements TransactionCategory
enum AllowanceCategory <<enumeration>> implements TransactionCategory
class Storage
interface TransactionCategory <<interface>>
class Parser
class Nuscents
class TransactionList
abstract class Command

TransactionList *-- Transaction : contains
Transaction <|-- Expense
Transaction <|-- Allowance
Transaction "*"--> "1" TransactionCategory

Nuscents "1" --> "1" Storage
Nuscents "1" --> "1" TransactionList
Nuscents "1" ..> "1" Parser
Nuscents "1" ..> "1" Command

Storage ..> TransactionList : uses

Parser ..> Command : creates
Parser ..> Transaction : creates
Parser ..> TransactionCategory : uses

Command ..> TransactionList : uses


@enduml
11 changes: 11 additions & 0 deletions docs/diagrams/StorageClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@startuml
!import style.puml
hide members
hide circle

Storage ..> "1" TransactionList : read/write
Storage ..> Parser : uses >

TransactionList *-- Transaction : contains >

@enduml
39 changes: 39 additions & 0 deletions docs/diagrams/UiClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@startuml
!import style.puml
hide members
hide circle
skinparam classAttributeIconSize 0
package Ui as UI{
class Ui {
- Scanner input
+ String getUserCommand()
+ {static} void showLine()
+ {static} void showWelcomeMessage()
+ {static} void showGoodbyeMessage()
+ {static} void showException(Exception)
+ {static} void showTransactionCount()
+ {static} void showTransactionAddedMessage(Transaction)
+ {static} void showTransactionRemovedMessage(Transaction)
+ {static} void showTransactionList(TransactionList)
- {static} String getNote(String)
- {static} String getDescription(Transaction)
+ {static} void showReadDataError()
+ {static} void showTransactionViewMessage(Transaction)
+ {static} void showFilterMessage(ArrayList<Transaction>,TransactionCategory)
+ {static} void showFilterNotFoundMessage(TransactionCategory)
+ {static} void showBudgetSet(TransactionList)
+ {static} void showBudgetExpense(TransactionList)
+ {static} void showHelpMenu()
+ {static} void showFileAccessErrorMessage()
+ {static} void showFatalErrorMessage()
+ {static} void showDataCorruptedError()
}
class Messages
}

TransactionList ..> Ui
Storage ..> Ui
Nuscents --> Ui
Command ..> Ui
Ui ..> Messages
@enduml
Binary file added docs/images/ParserClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/SimpleClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/StorageClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/UiClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1014962

Please sign in to comment.