Skip to content

Commit

Permalink
Merge pull request #72 from yellow-294/update-dg-addassginments
Browse files Browse the repository at this point in the history
Update DG with AddAssginments command
  • Loading branch information
cxyterence authored Oct 19, 2022
2 parents 9ba476f + bc9895e commit d99a4d0
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 0 deletions.
68 changes: 68 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Assignment>`
* `Student#setAssignments` Adds every Assignment in the user input into `ArrayList<Assignment>`

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
Expand Down
24 changes: 24 additions & 0 deletions docs/diagrams/AddAssignmentsDiagram1.puml
Original file line number Diff line number Diff line change
@@ -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 {
<u> :Person1 *-> alpha
<u> :Person2 *--> bravo
<u> :Person3 *---> charlie
<u> :Person4 *----> delta
}
@end
33 changes: 33 additions & 0 deletions docs/diagrams/AddAssignmentsDiagram2.puml
Original file line number Diff line number Diff line change
@@ -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 {
<u> :Person1 *-> alpha
<u> :Person2 *--> bravo
<u> :Person3 *---> charlie
<u> :Person4 *----> delta
}

map ":AddAssignmentsCommand" as AddAssignmentsCommand {

}

AddAssignmentsCommand --> alpha : check
AddAssignmentsCommand ---> bravo : check
AddAssignmentsCommand ----> charlie : check
AddAssignmentsCommand -----> delta : check
@end
56 changes: 56 additions & 0 deletions docs/diagrams/AddAssignmentsDiagram3.puml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions docs/diagrams/AddAssignmentsDiagram4.puml
Original file line number Diff line number Diff line change
@@ -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
Binary file added docs/images/AddAssignmentsDiagram1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/AddAssignmentsDiagram2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/AddAssignmentsDiagram3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/AddAssignmentsDiagram4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d99a4d0

Please sign in to comment.