Skip to content

Commit

Permalink
update DG
Browse files Browse the repository at this point in the history
  • Loading branch information
zoebelle-pang committed Apr 4, 2024
1 parent 7df92f2 commit 4758a4a
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,46 @@ The following activity diagram summarizes what happens when a tutor executes a f
* Pros: Useful for the entire application, and would use less memory (e.g. storing the first 10 commands).
* Cons: Harder to implement.

### Payment Command

#### Implementation

The payment command in the Address book application is implemented using the PaymentPredicate, which extends the Predicate functional interface.
This predicate is used to set a condition for filtering students based on whether they have paid or not paid.

The application allows updating the payment predicate using the Model#updateFilteredPersonList(predicate) method.

The Payment class is added as an additional data field in the Person class.
* When unspecified:
* `Payment()` equals to `Payment("-")` (i.e. "-" will be shown when there is no payment for the student.)

Given below is an example usage scenario and what the predicate is at each step.

Step 1. The user launches the application for the first time. The student's contacts in the form of FilteredList will be shown, where the predicate states that the payment condition is true for all.

Step 2. The user executes `Payment pa/paid` command to get all students in the `FilteredList` who has an "Paid". The `payment` command creates `PaymentFilterPredicate`, and calls `Model#updateFilteredPersonList(predicate)`, updating the list to show students that has "Paid".

![PaymentFilterState](images/FilterState2-PaymentFilteredList.png)

Calling `list` command will revert the predicate back to `Model.PREDICATE_SHOW_ALL_PERSONS`.

<br>
The following sequence diagram shows how a Payment filter operation goes through the `Logic` component:

![PaymentSequenceDiagram-Logic](images/PaymentSequenceDiagram-Logic.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** Similarly to filter command, the lifeline for `PaymentCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</div>

Similarly, how a filter operation goes through the `Model` component is shown below:

![FilterSequenceDiagram-Model](images/FilterSequenceDiagram-Model.png)

The following activity diagram summarizes what happens when a tutor executes a filter command.

![FilterActivityDiagram](images/PaymentActivityDiagram.png)

### View Command

#### Implementation
Expand Down
17 changes: 17 additions & 0 deletions docs/diagrams/FilterState2.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000
skinparam ClassBackgroundColor #FFFFAA

title FilteredList

package Predicates {
class State1 as "<u>Model.PREDICATE_SHOW_ALL_PERSONS</u>"
class State2 as "<u>:GradeSubjectFilterPredicate</u>"
}
State1 -[hidden]right-> State2

class Pointer as "Current State" #FFFFFF
Pointer -up-> State2
@end
14 changes: 14 additions & 0 deletions docs/diagrams/PaymentActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12
start
:User executes filter command;

'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.

:System updates filter predicate;
:Returns filtered student list;
stop
@enduml
55 changes: 55 additions & 0 deletions docs/diagrams/PaymentSequenceDiagram-Logic.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":PaymentCommand" as FilterCommand LOGIC_COLOR
participant ":PaymentFilterPredicate" as GradeSubjectFilterPredicate LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box
[-> LogicManager : execute(payment pa/...)
activate LogicManager

LogicManager -> AddressBookParser : parseCommand()
activate AddressBookParser

create GradeSubjectFilterPredicate
AddressBookParser -> GradeSubjectFilterPredicate
activate GradeSubjectFilterPredicate

GradeSubjectFilterPredicate --> AddressBookParser
deactivate GradeSubjectFilterPredicate

create FilterCommand
AddressBookParser -> FilterCommand
activate FilterCommand

FilterCommand --> AddressBookParser
deactivate FilterCommand

AddressBookParser --> LogicManager
deactivate AddressBookParser

LogicManager -> FilterCommand : execute()
activate FilterCommand

FilterCommand -> Model : updateFilteredPersonList(predicate)
activate Model

Model --> FilterCommand
deactivate Model

FilterCommand --> LogicManager : commandResult
deactivate FilterCommand
FilterCommand -[hidden]-> LogicManager : commandResult
destroy FilterCommand
destroy GradeSubjectFilterPredicate

[<--LogicManager
deactivate LogicManager
@enduml

0 comments on commit 4758a4a

Please sign in to comment.