diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index b21d2ab179d..b75db32579a 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -225,6 +225,74 @@ The following activity diagram summarizes what happens in AddressBookParser when * Pros: Does not modify the master address book. * Cons: May have performance issues in terms of memory usage. +### \[Proposed\] Add Assignments feature + +#### Proposed Implementation + +The proposed Add Assignments feature is facilitated by `AddAssignmentsCommand` and `AddAssignmentsCommandParser`. + +This feature allows assignments with weightages to be added to each `Student` in TAB. Weightages are separated from the assignment name with the prefix: `w/` + +The `AddAssignmentsCommandParser` parses the user input to check the validity of the Assignment. Then, every `Student` currently listed in TAB will be assigned these Assignments. This is done with the help of the following methods: + +* `Student#addAssignment` Adds a single Assignment into the `ArrayList` +* `Student#setAssignments` Adds every Assignment in the user input into `ArrayList` + +Listed below are the possible scenarios as well as the behavior of the feature in each scenario. + +Scenario 1: User inputs assignments with weightage that does not add up to 100% + +e.g. `assignments assignments/ Assignment 1 w/50, Finals w/40` + +It will be detected that the weightage of the assignments does not add up to 100 and a `CommandException` is thrown + +Scenario 2: User inputs assignments with negative weightage + +e.g. `assignments assignments/ Assignment 1 w/-50, Midterms w/50, Finals w/100` + +It will be detected that a particular assignment has a negative weightage and a `CommandException` is thrown + +Given below is an example usage scenario and how the Add Assignments mechanism behaves at each step. + +Step 1. The user launches the application. `TAB` will initially display all Persons + +![AddAssignmentsDiagram1](images/AddAssignmentsDiagram1.png) + +Step 2. The user executes `assignments assignments/ Assignment 1 w/15, Assignment 2 w/15, Midterms w/20, Finals w/50`. The `assignments` keyword +causes `AddressBookParser#parseCommand()` to call `AddAssignmentsCommandParser#parse()`. This returns a `AddAssignmentsCommand` + +Step 3. The internals of `AddAssignmentCommand` loops through all the people in the list, checking if they have the position of student + +![AddAssignmentsDiagram2](images/AddAssignmentsDiagram2.png) + +Step 4. `Assignment` objects will be created according to the user input and added to the `assignmentsList` field in `Student` + +The following sequence diagram shows how the AddAssignments operation works: + +![AddAssignmentsDiagram3](images/AddAssignmentsDiagram3.png) + +The following activity diagram summarizes what happens in AddressBookParser when a user executes a AddAssignment command: + +![AddAssignmentsDiagram4](images/AddAssignmentsDiagram4.png) + +Design considerations: + +Aspect: How AddAssignments executes: +* Alternative 1: Only adds assignments to indexed student + * Pros: Each student can have different assignments + * Cons: Will be tedious when there is a large number of students in `TAB` +* Alternative 2: Save Assignments in a json file to be read so every student added after will be automatically instanciated with those assignments + * Pros: Eliminates the need to run AddAssignments command for new students + * Cons: Difficulty in implementation + + + + + + + + + ### \[Proposed\] Undo/redo feature #### Proposed Implementation diff --git a/docs/diagrams/AddAssignmentsDiagram1.puml b/docs/diagrams/AddAssignmentsDiagram1.puml new file mode 100644 index 00000000000..4013595ca7e --- /dev/null +++ b/docs/diagrams/AddAssignmentsDiagram1.puml @@ -0,0 +1,24 @@ +@startuml +object "__alpha:Person__" as alpha { +role = Student +} + +object "__bravo:Person__" as bravo { +role = Student +} + +object "__charlie:Person__" as charlie { +role = Professor +} + +object "__delta:Person__" as delta { +role = TA +} + +map "__:TAB__" as Tab { + :Person1 *-> alpha + :Person2 *--> bravo + :Person3 *---> charlie + :Person4 *----> delta +} +@end diff --git a/docs/diagrams/AddAssignmentsDiagram2.puml b/docs/diagrams/AddAssignmentsDiagram2.puml new file mode 100644 index 00000000000..fc9d50592c9 --- /dev/null +++ b/docs/diagrams/AddAssignmentsDiagram2.puml @@ -0,0 +1,33 @@ +@startuml +object "__alpha:Person__" as alpha { +role = Student +} + +object "__bravo:Person__" as bravo { +role = Student +} + +object "__charlie:Person__" as charlie { +role = Professor +} + +object "__delta:Person__" as delta { +role = TA +} + +map "__:TAB__" as Tab { + :Person1 *-> alpha + :Person2 *--> bravo + :Person3 *---> charlie + :Person4 *----> delta +} + +map ":AddAssignmentsCommand" as AddAssignmentsCommand { + +} + +AddAssignmentsCommand --> alpha : check +AddAssignmentsCommand ---> bravo : check +AddAssignmentsCommand ----> charlie : check +AddAssignmentsCommand -----> delta : check +@end diff --git a/docs/diagrams/AddAssignmentsDiagram3.puml b/docs/diagrams/AddAssignmentsDiagram3.puml new file mode 100644 index 00000000000..6857b9e37c3 --- /dev/null +++ b/docs/diagrams/AddAssignmentsDiagram3.puml @@ -0,0 +1,56 @@ +@startuml +!include style.puml + +box Logic LOGIC_COLOR_T1 +participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":AddAssignmentsCommandParser" as AddAssignmentsCommandParser LOGIC_COLOR +participant ":AddAssignmentsCommand" as AddAssignmentsCommand LOGIC_COLOR +participant ":CommandResult" as CommandResult LOGIC_COLOR +end box + +box Model MODEL_COLOR_T1 +participant ":Model" as Model MODEL_COLOR +end box + + + +[-> AddressBookParser : parseCommand(assignments) +activate AddressBookParser + +create AddAssignmentsCommandParser +AddressBookParser -> AddAssignmentsCommandParser: +activate AddAssignmentsCommandParser + +AddAssignmentsCommandParser --> AddressBookParser +deactivate AddAssignmentsCommandParser + +AddressBookParser -> AddAssignmentsCommandParser: parse() +activate AddAssignmentsCommandParser + +create AddAssignmentsCommand +AddAssignmentsCommandParser -> AddAssignmentsCommand: parse() +activate AddAssignmentsCommand + +create Model +AddAssignmentsCommand -> Model: setPerson() +activate Model + +Model --> AddAssignmentsCommand +deactivate Model + +create CommandResult +AddAssignmentsCommand -> CommandResult: execute() +activate CommandResult + +CommandResult --> AddAssignmentsCommand +deactivate CommandResult + +AddAssignmentsCommand --> AddAssignmentsCommandParser +deactivate AddAssignmentsCommand + +AddAssignmentsCommandParser --> AddressBookParser +deactivate AddAssignmentsCommandParser + +[<-- AddressBookParser +deactivate AddressBookParser +@enduml diff --git a/docs/diagrams/AddAssignmentsDiagram4.puml b/docs/diagrams/AddAssignmentsDiagram4.puml new file mode 100644 index 00000000000..82084081ac3 --- /dev/null +++ b/docs/diagrams/AddAssignmentsDiagram4.puml @@ -0,0 +1,17 @@ +@startuml +start +:User executes command; + +'Since the beta syntax does not support placing the condition outside the +'diamond we place it as the true branch instead. + +if () then ([command is valid]) + :Parse inputs; + :Iterates TAB for Students; + :Creates Assignment objects and add them to an + ArrayList encapsulated in Student; +else ([else]) + :Display error; +endif +stop +@enduml diff --git a/docs/images/AddAssignmentsDiagram1.png b/docs/images/AddAssignmentsDiagram1.png new file mode 100644 index 00000000000..f46b0156bcb Binary files /dev/null and b/docs/images/AddAssignmentsDiagram1.png differ diff --git a/docs/images/AddAssignmentsDiagram2.png b/docs/images/AddAssignmentsDiagram2.png new file mode 100644 index 00000000000..7884586a97e Binary files /dev/null and b/docs/images/AddAssignmentsDiagram2.png differ diff --git a/docs/images/AddAssignmentsDiagram3.png b/docs/images/AddAssignmentsDiagram3.png new file mode 100644 index 00000000000..f667363bdb8 Binary files /dev/null and b/docs/images/AddAssignmentsDiagram3.png differ diff --git a/docs/images/AddAssignmentsDiagram4.png b/docs/images/AddAssignmentsDiagram4.png new file mode 100644 index 00000000000..5a500b949e0 Binary files /dev/null and b/docs/images/AddAssignmentsDiagram4.png differ