Skip to content

Commit

Permalink
Merge pull request #98 from yorklim/DevGuide
Browse files Browse the repository at this point in the history
Add addpolicy feature implementation to DevGuide
  • Loading branch information
ReganChoy authored Mar 27, 2024
2 parents a22327e + 409de12 commit 4baa25e
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 10 deletions.
26 changes: 26 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,32 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa

This section describes some noteworthy details on how certain features are implemented.

### Add policy feature
The add policy feature allows users to add a policy to a client. The policy is stored in the `Policy` class, which contains the policy details such as policy name, policy id. The `Policy` class is then added to the `PolicyList` object stored within the `Person` object in the `Model` component.

#### Implementation

The add policy command mechanism is facilitated by the `AddPolicyCommandParser` class which is created by the `AddressBookParser`.

The `AddPolicyCommandParser` class is responsible for parsing the user input and creating an `AddPolicyCommand` object.

The `AddPolicyCommandParser#parse()` overrides `Parser#parse()` in the `Parser` interface.
- `AddPolicyCommandParser#parse()` - Parses the input arguments by storing the prefixes of it respective values in a `ArgumentMultimap` object, and creates a new `AddPolicyCommand` object with the parsed policy name and policy ID.

The `AddPolicyCommand` object is then executed by the `Logic` component.

The `AddPolicyCommand` object then communicates with the `Model` component to add the policy to the client. The `Model` component then updates the `Person` object with the new policy.
- `Model#setPerson(Person, Person)` - Sets the client in the existing client list to the new `Person` object which has been edited by the `AddPolicyCommand#execute()` which contains the new policy.
- `Model#setDisplayClient(Person)` - Updates the displayed client in the UI to the client that has been edited with the new policy.

The method `AddPolicyCommand#execute()` returns a CommandResult object which contains the success message to be displayed to the user.

The following object diagram illustrates the above:
<puml src="diagrams/AddPolicyObjectDiagram.puml" width="600" />

The following sequence diagram shows the addpolicy operation:
<puml src="diagrams/AddPolicySequenceDiagram.puml" width="900" />

### \[Proposed\] Undo/redo feature

#### Proposed Implementation
Expand Down
20 changes: 10 additions & 10 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ You might encounter these call-outs while reading through the guide, which conta

<box type="tip">

**Tip:** Tip call-outs like this contain helpful pointers for using ClientCare!
**Tip:** Tip call-outs like this contain helpful pointers for using ClientCare!
</box>

<box type="info">

**Note:** Information call-outs like this contain information about ClientCare you should take note of!
**Note:** Information call-outs like this contain information about ClientCare you should take note of!
</box>

<box type="warning" theme="danger" icon=":warning:">
Expand All @@ -80,24 +80,24 @@ You might encounter these call-outs while reading through the guide, which conta


## Introduction
Made for insurance agents and clients, by insurance agents and clients.
Made for insurance agents and clients, by insurance agents and clients.
ClientCare is the easiest way to manage your clients and schedules, all in one place.
Powerful features and intuitive design, all packaged into one neat desktop app. ClientCare is supported on all
major platforms (Windows, macOS).


#### Let ClientCare assist you in...

1. [**Managing your clients**](#client-related-commands)
1. [**Managing your clients**](#client-related-commands)
ClientCare lets you store, edit and delete your client's information. Keep all your clients' details in one place and save time!


2. [**Planning your schedule**](#schedule-related-commands)
2. [**Planning your schedule**](#schedule-related-commands)
Meeting clients are part of the job. Not sure when to meet your next client? ClientCare reminds you of clients that you may have
missed out!


3. [**Keeping track of policies**](#policy-related-commands)
3. [**Keeping track of policies**](#policy-related-commands)
Too many policies from different companies? Why not track all of them in one place! ClientCare allows you to attach policies
to all your clients, regardless of companies and product type.

Expand Down Expand Up @@ -238,7 +238,7 @@ Alternatively, [Command Summary](#command-summary) has all of them under one pag
<div style="page-break-after: always;"></div>

## Quick Tutorial
Excited to play around with ClientCare?
Excited to play around with ClientCare?
Let’s run you through some simple commands to get you warmed up before you dive right into ClientCare’s full feature list!

<box type="info">
Expand All @@ -263,7 +263,7 @@ Type the following into the Command Input:
![addclient](images/ug/addclient.png =600x)


2. We have now added James Wee to our Client List! ClientCare shows a success message in the Feedback Display too.
2. We have now added James Wee to our Client List! ClientCare shows a success message in the Feedback Display too.



Expand Down Expand Up @@ -450,7 +450,7 @@ Examples:

<box type="tip">

**Tip:** You can use `find` to more easily find the client you want for commands that require a client `INDEX`!
**Tip:** You can use `find` to more easily find the client you want for commands that require a client `INDEX`!
</box>

<br/>
Expand All @@ -476,7 +476,7 @@ ClientCare offers the following commands to help you manage your schedule:
* [Updating last met: `met`](#updating-last-met-met)
* [Scheduling an appointment: `schedule`](#scheduling-appointments-schedule)
* [Marking an appointment: `mark`](#marking-appointments-mark)

<br>
<br>

Expand Down
26 changes: 26 additions & 0 deletions docs/diagrams/AddPolicyObjectDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@startuml
!include style.puml
skinparam objectFontColor white

object "<u>:AddPolicyCommand</u>" as AddPolicyCommand LOGIC_COLOR
object "<u>:AddPolicyCommandParser</u>" as AddPolicyCommandParser LOGIC_COLOR
object "<u>:AddressBookParser</u>" as AddressBookParser LOGIC_COLOR
object "<u>:Model</u>" as Model MODEL_COLOR
object "<u>:CommandResult</u>" as CommandResult LOGIC_COLOR
object "<u>policyAddedPerson:Person" as Person1 LOGIC_COLOR
object "<u>personToAddPolicy:Person" as Person2 LOGIC_COLOR
object "<u>:ArgumentMultimap" as ArgumentMultimap LOGIC_COLOR
object "<u>:ParserUtil" as ParserUtil LOGIC_COLOR

AddressBookParser --> AddPolicyCommandParser : calls
AddressBookParser --> AddPolicyCommand
AddPolicyCommandParser -> AddPolicyCommand
AddPolicyCommandParser --> ArgumentMultimap : instantiates
ParserUtil --> ArgumentMultimap : parses
AddPolicyCommand --> Person1
AddPolicyCommand --> Person2
AddPolicyCommand --> Model
AddPolicyCommand -right-> CommandResult : outputs
Model --> Person2 : Removes
Model --> Person1 : Updates
@enduml
60 changes: 60 additions & 0 deletions docs/diagrams/AddPolicySequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@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 "a:AddPolicyCommand" as AddPolicyCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box
[-> LogicManager : execute("addpolicy 1 n/Travel i/1")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("addpolicy 1 n/Travel i/1")
activate AddressBookParser

create AddPolicyCommand
AddressBookParser -> AddPolicyCommand : AddPolicyCommand(1, newPolicy)
activate AddPolicyCommand

AddPolicyCommand --> AddressBookParser
deactivate AddPolicyCommand

AddressBookParser --> LogicManager : a
deactivate AddressBookParser

LogicManager -> AddPolicyCommand : execute()
activate AddPolicyCommand

AddPolicyCommand -> Model : setPerson(personToAddPolicy, policyAddedPerson)
activate Model

Model --> AddPolicyCommand
deactivate Model

AddPolicyCommand -> Model : setDisplayClient(policyAddedPerson)
activate Model

Model --> AddPolicyCommand
deactivate Model

create CommandResult
AddPolicyCommand --> CommandResult
activate CommandResult

CommandResult --> AddPolicyCommand
deactivate CommandResult

AddPolicyCommand --> LogicManager : result
deactivate AddPolicyCommand
AddPolicyCommand -[hidden]-> LogicManager : result
destroy AddPolicyCommand

[<--LogicManager
deactivate LogicManager
@enduml

0 comments on commit 4baa25e

Please sign in to comment.