forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into branch-add-diagram
- Loading branch information
Showing
9 changed files
with
227 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
* This project is based on the AddressBook-Level3 project created by the [SE-EDU initiative](https://se-education.org/). | ||
* We took references from [OpenCSV](https://opencsv.sourceforge.net/) for import and export commands. | ||
* ChatGPT was used to check for errors and generate some test cases. | ||
* It was used to generate the first two test cases in RemoveGradeCommandParserTest.java | ||
* It was used to generate the first two test cases in RemoveGradeCommandParserTest.java, MarkCommandParserTest.java & MarkCommandTest.java. | ||
* It was also used for the usage of `.getStyleClass()` & `.add()` methods in PersonCard.java to display the information clearly. | ||
* It was consulted to get a plan of how `PersonComparator` can be implemented. | ||
* It was consulted to fix and improve the UI. | ||
|
@@ -74,7 +74,6 @@ Each of the four main components (also shown in the diagram above), | |
- defines its _API_ in an `interface` with the same name as the Component. | ||
- implements its functionality using a concrete `{Component Name}Manager` class (which follows the corresponding API `interface` mentioned in the previous point. | ||
|
||
{{ newPage }} | ||
|
||
For example, the `Logic` component defines its API in the `Logic.java` interface and implements its functionality using the `LogicManager.java` class which follows the `Logic` interface. Other components interact with a given component through its interface rather than the concrete class (reason: to prevent outside component's being coupled to the implementation of a component), as illustrated in the (partial) class diagram below. | ||
|
||
|
@@ -195,6 +194,53 @@ This section describes some noteworthy details on how certain features are imple | |
|
||
--- | ||
|
||
### Add contacts | ||
|
||
**Overview** | ||
|
||
The `add` command allows user to add students' contact into KonTActs. | ||
|
||
The Sequence Diagram below shows how the logic component handles the user input. | ||
|
||
<puml src="diagrams/AddSequenceDiagram.puml" width="550"/> | ||
|
||
Note: While the diagram shows the lifeline of objects even after their deletion, this is a limitattion of plantUML. | ||
|
||
**Details** | ||
|
||
1. The user inputs "add n/John tele/@John g/Johnny e/[email protected]". (Not shown in diagram) | ||
2. The `LogicManager` object will be called to `execute` the input. | ||
3. The `AddressBookParser` will identify the type of command is `AddCommand`, before creating a `AddCommandParser` to parse the details. | ||
4. The `AddCommandParser` will `parse` the `USER_DETAILS` before creating a `AddCommand`. | ||
5. The new `AddCommand` will be returned to `LogicManager`. | ||
6. The `LogicManager` will then calls `exectute` on `AddCommand` while providing the model. | ||
7. This causes the `AddCommand` to call the `addPerson` method of model, adding the person to the model. | ||
8. A `CommandResult` object is subsequently created which indicates the success of `AddCommand`. | ||
|
||
**Example Usage** | ||
1. User inputs the command "add n/Tom tele/@Tom g/Tommy e/[email protected]". | ||
2. KonTActs will create a contact of Tom with the given details before adding it to the contact list. | ||
3. The contact is then displayed in the UI, along with a success message. | ||
|
||
--- | ||
|
||
### MarkCommand | ||
|
||
<puml src="diagrams/MarkCommandActivityDiagram.puml" width="750" /> | ||
|
||
|
||
* The `MarkCommand` is used by KonTActs to allow TAs to mark the attendance for a student. | ||
* It follows the activity diagram as shown above where it first checks if the person exists. | ||
* If the person exists, it will check if the weeksPresent contains the week to be marked. | ||
* If the weeksPresent does not contain the week to be marked yet, it will add it in and return a success message. Else it will throw a mark already success message to tell the TA that the attendance for the TA for that week has been marked. | ||
|
||
**Example Usage** | ||
1. User inputs the command "mark n/John Doe w/1". | ||
2. KonTActs will set the week 1 attendance for John Doe to be true. | ||
3. The update is then displayed in the UI, along with a success message. | ||
|
||
--- | ||
|
||
### Export Command implementation | ||
**API** [`Export.java`](https://github.com/AY2425S1-CS2103T-T11-2/tp/blob/master/src/main/java/seedu/address/storage/Export.java) | ||
|
||
|
@@ -212,6 +258,37 @@ A visual representation is shown below of how a typical user might use the `Expo | |
|
||
<puml src="diagrams/Export.puml" width="550"></puml> | ||
|
||
--- | ||
|
||
### Command History implementation | ||
**API** : [`CommandHistory.java`](https://github.com/AY2425S1-CS2103T-T11-2/tp/blob/master/src/main/java/seedu/address/storage/CommandHistory.java) | ||
|
||
The `CommandHistory` is used by KonTActs to allow users to navigate and retrieve previous inputted commands. It follows a singleton pattern where only a single instance can be created. | ||
|
||
- `CommandHistory` makes use of an `ArrayList` to store the commands of the current user session. | ||
- The `ArrayList` is destroyed at the end of the program and a new one will be created at the start of every session of KonTActs. | ||
- An `index` points to the current command displayed in the command box of the Graphical user interface (GUI). | ||
|
||
When a user enters a command, | ||
1. If an existing `CommandHistory` instance already exists, then the command will be added to it | ||
2. Else, a new `CommandHistory` instance will be instantiated and the command will be added to it | ||
|
||
This is illustrated in the activity diagram below: | ||
<center> | ||
<puml src="diagrams/commandHistoryActivityDiagram.puml" width="450" /> | ||
</center> | ||
|
||
When a user retrieves a command that was previously executed using <kbd>↑</kbd> or <kbd>↓</kbd>, | ||
- `CommandHistory` instance first checks if there are fields in the `ArrayList` of the `CommandHistory` instance. | ||
- `CommandHistory` instance then checks for the correct `index`. (i.e. The `index` is valid when it is between 0 and the size of the `ArrayList`). | ||
|
||
If both conditions are satisfied, the `ArrayList` is accessed with the `index` and the command string (that was previously entered) will be returned and displayed on the command box of the GUI. | ||
|
||
A visual representation is shown below of how a typical user might use the `CommandHistory`, | ||
|
||
<center> | ||
<puml src="diagrams/commandHistoryUserInteractionActivityDiagram.puml" width="700" /> | ||
</center> | ||
|
||
{{ newPage }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@startuml | ||
start | ||
:User keys in MarkCommand with name and week; | ||
|
||
:Retrieve person from Model using name; | ||
|
||
if () then ([Person not found]) | ||
:Throw MESSAGE_INVALID_PERSON_DISPLAYED_NAME; | ||
stop | ||
else ([Else]) | ||
:Retrieve weeksPresent for the person; | ||
if () then ([Week already marked]) | ||
:Return MESSAGE_MARK_ALREADY_SUCCESS; | ||
stop | ||
else ([Else]) | ||
:Add week to weeksPresent; | ||
:Update person with new weeksPresent; | ||
:Save updated person back to Model; | ||
:Return MESSAGE_MARK_SUCCESS; | ||
stop | ||
endif | ||
endif | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@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 ":AddCommandParser" as AddCommandParser LOGIC_COLOR | ||
participant "a:AddCommand" as AddCommand LOGIC_COLOR | ||
participant "r:CommandResult" as CommandResult LOGIC_COLOR | ||
end box | ||
|
||
box Model MODEL_COLOR_T1 | ||
participant "m:Model" as Model MODEL_COLOR | ||
end box | ||
|
||
[-> LogicManager : execute("add n/John tele/@John \n g/Johnny e/[email protected]") | ||
note left of LogicManager: From this point on we will refer\n "add n/John tele/@John g/Johnny e/[email protected]" \n as USER_DETAILS | ||
activate LogicManager | ||
|
||
LogicManager -> AddressBookParser : parseCommand("add USER_DETAILS") | ||
activate AddressBookParser | ||
|
||
create AddCommandParser | ||
AddressBookParser -> AddCommandParser | ||
activate AddCommandParser | ||
|
||
AddCommandParser --> AddressBookParser | ||
deactivate AddCommandParser | ||
|
||
AddressBookParser -> AddCommandParser : parse(USER_DETAILS) | ||
activate AddCommandParser | ||
|
||
create AddCommand | ||
AddCommandParser -> AddCommand | ||
activate AddCommand | ||
|
||
AddCommand --> AddCommandParser : | ||
deactivate AddCommand | ||
|
||
AddCommandParser --> AddressBookParser : a | ||
deactivate AddCommandParser | ||
'Hidden arrow to position the destroy marker below the end of the activation bar. | ||
AddCommandParser -[hidden]-> AddressBookParser | ||
destroy AddCommandParser | ||
|
||
AddressBookParser --> LogicManager : a | ||
deactivate AddressBookParser | ||
|
||
LogicManager -> AddCommand : execute(m) | ||
activate AddCommand | ||
|
||
AddCommand -> Model : addPerson(person) | ||
activate Model | ||
|
||
Model --> AddCommand | ||
deactivate Model | ||
|
||
create CommandResult | ||
AddCommand -> CommandResult | ||
activate CommandResult | ||
|
||
CommandResult --> AddCommand | ||
deactivate CommandResult | ||
'Hidden arrow to position the destroy marker below the end of the activation bar. | ||
CommandResult -[hidden]-> AddCommand | ||
destroy CommandResult | ||
|
||
AddCommand --> LogicManager : r | ||
deactivate AddCommand | ||
'Hidden arrow to position the destroy marker below the end of the activation bar. | ||
AddCommand -[hidden]-> LogicManager | ||
destroy AddCommand | ||
|
||
[<--LogicManager | ||
deactivate LogicManager | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@startuml | ||
'https://plantuml.com/activity-diagram-beta | ||
|
||
start | ||
:User types a command input; | ||
if () then ([CommandHistory exists]) | ||
|
||
else ([else]) | ||
:KonTActs creates a new CommandHistory; | ||
endif | ||
|
||
:User input command is added to CommandHistory; | ||
|
||
|
||
stop | ||
|
||
@enduml |
23 changes: 23 additions & 0 deletions
23
docs/diagrams/commandHistoryUserInteractionActivityDiagram.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@startuml | ||
'https://plantuml.com/activity-diagram-beta | ||
|
||
start | ||
:User access previous command | ||
using the keyboard up key; | ||
if () then ([CommandHistory exists]) | ||
if () then ([CommandHistory is empty]) | ||
: KonTActs informs users that | ||
there is no previous commands; | ||
else ([CommandHistory is not empty])]) | ||
:KonTActs gets previous command | ||
from the CommandHistory's ArrayList; | ||
:Previous command is displayed to the user; | ||
endif | ||
else ([CommandHistory does not exist]) | ||
:KonTActs creates a new CommandHistory; | ||
:KonTActs informs users | ||
that there is no previous commands; | ||
endif | ||
stop | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters