Skip to content

Commit

Permalink
Merge branch 'master' of github.com:AY2425S1-CS2113-W13-4/tp into Zih…
Browse files Browse the repository at this point in the history
…an-DG-1

* 'master' of github.com:AY2425S1-CS2113-W13-4/tp:
  Add DeleteComponentCommand UML png
  Add DeleteComponentCommand UML
  Update DG for AddGradeCommand and DeleteGradeCommand
  Add AddComponentCommand UML png
  Add AddComponentCommand UML
  Make minor edits to UG
  • Loading branch information
jinzihan2002 committed Oct 29, 2024
2 parents 7d0aa2c + 6e71635 commit 3ec735e
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 17 deletions.
23 changes: 12 additions & 11 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,26 @@ The `AddGradeCommand` and `DeleteGradeCommand` classes handle the addition and d

#### Example Usage Scenario

Step 1: The user has launched the application, with students and graded components already registered in TutorLink.
Given below is an example usage scenario and how the AddGradeCommand and DeleteGradeCommand behaves at each step.

Step 2: The user issues a command (e.g., `add_grade`), which the parser processes, creating an `AddGradeCommand` instance and a `HashMap` containing the relevant parameters.
Consider a scenario where the Professor wants to add a grade for a student, Alice, in the midterm component of a module. The Professor would initiate the AddGradeCommand, inputting Alice's matriculation number, the component as "midterm," and a score of 85. The command will then:

Step 3: `AddGradeCommand` is executed within the `TutorLink`, receiving both the current app state and the `HashMap` of arguments.
1. Validate Alice's matriculation number and ensure that the midterm component is present in the grade configuration for the module.
2. Confirm that the score of 85 is within the allowable range for midterm.
3. Create a new Grade object and add it to the GradeList in AppState, reflecting Alice's score for the midterm component.

Step 4: The command extracts `matricNumber`, `componentDescription`, and `scoreNumber` from the `HashMap`. If any parameter is `null`, an `IllegalValueException` is thrown.
The sequence diagram of the DeleteGradeCommand is shown below.

Step 5: The specified component is located within the application using `componentDescription`. If no match is found or duplicates exist, an exception is thrown.
![AddGradeCommand.png](diagrams%2FAddGradeCommand.png)

Step 6: The student is identified using `matricNumber`, with exceptions raised for missing or duplicate entries.
Later, if the Professor realizes that the grade was entered incorrectly and decides to delete it, they can use the DeleteGradeCommand:

Step 7: The `scoreNumber` is converted to a `double` and checked to ensure it is within the acceptable range for the component. Negative values, scores exceeding the component maximum, or non-numeric inputs result in an exception.
1. The command verifies Alice's matriculation number and the midterm component's presence.
2. It locates Alice's midterm Grade object and deletes it from the GradeList in AppState, effectively removing the grade record.

Step 8: Using the `double` score and the identified student and component, a `Grade` object is created.
The sequence diagram of the DeleteGradeCommand is shown below.

Step 9: The new `Grade` object is added to the `GradeList`.

![AddGradeCommandDiagram.png](diagrams%2FAddGradeCommandDiagram.png)
![DeleteGradeCommand.png](diagrams%2FDeleteGradeCommand.png)

### Storage Load feature

Expand Down
7 changes: 4 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Adds a student to your class.

- **Example**:
- `add_student i/A1234567X n/John Doe ` adds a new student named John Doe with the matric number of A1234567X to the class.

---

### Deleting a Student: `delete_student`
Expand Down Expand Up @@ -130,8 +129,10 @@ Displays all grading components and their respective weights for a class.
- `list_component`

---


## Notes:
- Matric Number (`i/` argument) is case insensitive. Therefore, `A1234567X` is the same as `a1234567x`. Matric numbers
will be converted to uppercase for storage.
- (coming soon) All other arguments are case insensitive and will be converted to lowercase for storage.
## FAQ

**Q**: How do I transfer my data to another computer?
Expand Down
Binary file added docs/diagrams/AddComponentCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions docs/diagrams/AddComponentCommand.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@startuml
!include Style.puml
group sd AddComponentCommand
participant ":AddComponentCommand" as C LOGIC_COLOR_3
participant ":AppState" as A LOGIC_COLOR_2
participant ":HashMap<String, String>" as H LOGIC_COLOR_7
participant ":CommandResult" as R LOGIC_COLOR_8

[-> C
C -> H : get("c/")
activate H
C <-- H : componentName
deactivate H
C -> H : get("w/")
activate H
C <-- H : weightageNumber
deactivate H
C -> H : get("m/")
activate H
C <-- H : maxScoreNumber
deactivate H

opt componentName or weightageNumber or maxScoreNumber is null
[<-- C : throw IllegalValueException
end

C -> C : convertWeightageToValidDouble(weightageNumber)
activate C
C --> C : weightageNumber
deactivate C

C -> C : convertMaxScoreToValidDouble(maxScore)
activate C
C --> C : maxScore
deactivate C

C -> A : addComponent(new Component(componentName, maxScore, weightage))
activate A
C <-- A
deactivate A

create R
C -> R : new CommandResult
activate R
C <-- R : CommandResult
deactivate R

[<-- C : CommandResult
end
@enduml
Binary file modified docs/diagrams/AddGradeCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions docs/diagrams/AddGradeCommand.puml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ participant ":CommandResult" as R LOGIC_COLOR_8
participant ":Grade" as G LOGIC_COLOR_5

[->C

activate C
C -> H : get("i/")
activate H
C <-- H : matricNumber
Expand All @@ -25,8 +25,8 @@ activate H
C <-- H : scoreNumber
deactivate H

opt matricNumber is null
[<--C : throw IllegalValueException
opt matricNumber or componentDescription or scoreNumber is null
[<--C : throw IllegalValueException
end

C -> C : findComponentFromComponents
Expand Down Expand Up @@ -71,6 +71,7 @@ C <-- R : CommandResult
deactivate R

[<-- C : CommandResult
deactivate C

end

Expand Down
Binary file removed docs/diagrams/AddGradeCommandDiagram.png
Binary file not shown.
Binary file added docs/diagrams/DeleteComponentCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions docs/diagrams/DeleteComponentCommand.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@startuml
!include Style.puml
group sd DeleteComponentCommand
participant ":DeleteComponentCommand" as C LOGIC_COLOR_3
participant ":AppState" as A LOGIC_COLOR_2
participant ":HashMap<String, String>" as H LOGIC_COLOR_7
participant ":ComponentList" as CL LOGIC_COLOR_6
participant ":CommandResult" as R LOGIC_COLOR_8

[-> C

C -> H : get("n/")
activate H
C <-- H : componentName
deactivate H

opt componentName is null
[<-- C : throw IllegalValueException
end

C -> A : findComponent(componentName)
activate A
A --> C : componentsToDelete
deactivate A

alt componentsToDelete.size() == 0
<-- C : throw ComponentNotFoundException
else componentsToDelete.size() > 1
<-- C : throw DuplicateComponentException
end

C -> A : deleteComponent(componentsToDelete.getComponentArrayList().get(0))
activate A
C <-- A
deactivate A

create R
C -> R : new CommandResult
activate R
C <-- R : CommandResult
deactivate R


[<-- C : CommandResult
end
@enduml
Binary file added docs/diagrams/DeleteGradeCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/diagrams/DeleteGradeCommand.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'@@author yeekian
@startuml
!include Style.puml
group sd DeleteGradeCommand
participant ":DeleteGradeCommand" as C LOGIC_COLOR_3
participant ":AppState" as A LOGIC_COLOR_2
participant ":HashMap<String, String>" as H LOGIC_COLOR_7
participant ":CommandResult" as R LOGIC_COLOR_8

[->C
activate C
C -> H : get("i/")
activate H
C <-- H : matricNumber
deactivate H

C -> H : get("c/")
activate H
C <-- H : componentDescription
deactivate H

opt matricNumber or componentDescription is null
[<--C : throw IllegalValueException
end

C -> C : findComponentFromComponents
activate C
C -> A : findComponent(componentDescription)
activate A
C <-- A : componentFilteredList
deactivate A
C --> C : component
deactivate C


C -> A : findStudentByMatricNumber(matricNumber)
activate A
C <-- A : studentFilteredList
deactivate A

C -> A : deleteGrade(matricNumber, componentDescription)
activate A
C <-- A
deactivate A

create R
C -> R : new CommandResult
activate R
C <-- R : CommandResult
deactivate R

[<-- C : CommandResult
deactivate C

end


@enduml

0 comments on commit 3ec735e

Please sign in to comment.