Skip to content

Commit

Permalink
Merge pull request #227 from bertrandong/update-dg-final
Browse files Browse the repository at this point in the history
Update dg with product menu commands
  • Loading branch information
bertrandong authored Apr 13, 2024
2 parents c9ce4f6 + 745b9e9 commit f6b796f
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,44 @@ After parsing the `cancel` command, the `LogicManager` will call the `Model#dele
5. If `PREFIX_ADDRESS`, a `FindPersonCommand` with a `AddressContainsKeywordsPredicate` will be created.

The `Predicate` will then be used to filter the list using `stream()`. The updated `FilteredOrderList` will then be reflected in the GUI.

### Add a product to menu feature

Adds a `Product` to the menu. Example: `menu pn/Cupcake pc/2.50 ps/5`. The sequence of events are illustrated by the diagram below, starting with the parsing of the command.

![AddMenuCommandSequenceDiagram](images/AddMenuSequenceDiagram-Logic.png)

The `AddMenuCommand` class which extends the `Command` abstract class will be executed by the `LogicManager` which will update the `Product Menu` in the `Model`.

![AddMenuCommandModelDiagram](images/AddMenuSequenceDiagram-Model.png)

After parsing the `menu` command, the `LogicManager` will call the `Model#addProduct(id)` which calls `AddressBook#addProduct(id)`. The `addProduct` of `ProductMenu` will then be called, which will add a new product to the `ArrayList<Product>`.

### Delete a product from menu feature

Deletes a `Product` from the menu. Example: `delete m/1`. The sequence of events are illustrated by the diagram below, starting with the parsing of the command.

![DeleteMenuCommandSequenceDiagram](images/DeleteMenuSequenceDiagram-Logic.png)

The `DeleteMenuCommand` class which extends the `Command` abstract class will be executed by the `LogicManager` which will update the `Product Menu` in the `Model`.

![DeleteMenuCommandModelDiagram](images/DeleteMenuSequenceDiagram-Model.png)

After parsing the `menu` command, the `LogicManager` will call the `Model#deleteProduct(id)` which calls `AddressBook#deleteProduct(id)`. The `deleteProduct` of `ProductMenu` will then be called, which deletes a product from the `ArrayList<Product` according to the specified `MENU_ID`.

`DeleteCommandParser` will construct the respective command based on the accompanying prefixes:
1. If `PREFIX_MENU`, a `DeleteMenuCommand` will be created.
2. If `PREFIX_CUSTOMER_ID`, a `DeleteCustomerCommand` will be created.

### Edit a product in the menu feature

Edits a `Product` on the menu. Example: `edit m/1 pn/Pie`. The `edit` command works in a similar way as the `delete` command.

`EditCommandParser` will construct the respective command based on the accompanying prefixes:
1. If `PREFIX_MENU`, a `EditMenuCommand` will be created.
2. If `PREFIX_CUSTOMER_ID`, a `EditCustomerCommand` will be created.
3. If `PREFIX_ORDER_ID`, an `EditOrderCommand` will be created.

### Known Limitations
1. As `StringUtil#containsWordIgnoreCase` searches by entire word, searching for `945` in `94567122` for `Phone` will result in false. This is also consistent in `Email`.

Expand Down
70 changes: 70 additions & 0 deletions docs/diagrams/AddMenuSequenceDiagram-Logic.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@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 ":AddMenuCommandParser" as AddMenuCommandParser LOGIC_COLOR
participant "a:AddMenuCommand" as AddMenuCommand 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("menu pn/Cupcake pc/2.50 ps/5")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("menu pn/Cupcake pc/2.50 ps/5")
activate AddressBookParser

create AddMenuCommandParser
AddressBookParser -> AddMenuCommandParser
activate AddMenuCommandParser

AddMenuCommandParser --> AddressBookParser
deactivate AddMenuCommandParser

AddressBookParser -> AddMenuCommandParser : parse("pn/Cupcake pc/2.50 ps/5")
activate AddMenuCommandParser

create AddMenuCommand
AddMenuCommandParser -> AddMenuCommand
activate AddMenuCommand

AddMenuCommand --> AddMenuCommandParser :
deactivate AddMenuCommand

AddMenuCommandParser --> AddressBookParser : a
deactivate AddMenuCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
AddMenuCommandParser -[hidden]-> AddressBookParser
destroy AddMenuCommandParser

AddressBookParser --> LogicManager : a
deactivate AddressBookParser

LogicManager -> AddMenuCommand : execute(m)
activate AddMenuCommand

AddMenuCommand -> Model : deleteProduct(id)
activate Model

Model --> AddMenuCommand
deactivate Model

create CommandResult
AddMenuCommand -> CommandResult
activate CommandResult

CommandResult --> AddMenuCommand
deactivate CommandResult

AddMenuCommand --> LogicManager : r
deactivate AddMenuCommand

[<--LogicManager
deactivate LogicManager
@enduml
33 changes: 33 additions & 0 deletions docs/diagrams/AddMenuSequenceDiagram-Model.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
participant ":AddressBook" as AddressBook MODEL_COLOR
end box

box ProductMenu
participant ":ProductMenu" as ProductMenu
end box

[-> Model : deleteProduct(id)
activate Model

Model -> AddressBook : deleteProduct(id)
activate AddressBook

AddressBook -> ProductMenu :deleteProduct(id)
activate ProductMenu

ProductMenu -> ProductMenu :deleteProduct(id)
ProductMenu -> AddressBook
deactivate ProductMenu

AddressBook --> Model :
deactivate AddressBook

[<-- Model
deactivate Model

@enduml
87 changes: 87 additions & 0 deletions docs/diagrams/DeleteMenuSequenceDiagram-Logic.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@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 ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR
participant ":DeleteMenuCommandParser" as DeleteMenuCommandParser LOGIC_COLOR
participant "d:DeleteMenuCommand" as DeleteMenuCommand 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("delete m/1")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("delete m/1")
activate AddressBookParser

create DeleteCommandParser
AddressBookParser -> DeleteCommandParser
activate DeleteCommandParser

DeleteCommandParser --> AddressBookParser
deactivate DeleteCommandParser

AddressBookParser -> DeleteCommandParser : parse("m/1")
activate DeleteCommandParser

create DeleteMenuCommandParser
DeleteCommandParser -> DeleteMenuCommandParser
activate DeleteMenuCommandParser

DeleteMenuCommandParser --> DeleteCommandParser
deactivate DeleteMenuCommandParser

DeleteCommandParser -> DeleteMenuCommandParser : parse("1")
activate DeleteMenuCommandParser

create DeleteMenuCommand
DeleteMenuCommandParser -> DeleteMenuCommand
activate DeleteMenuCommand

DeleteMenuCommand --> DeleteMenuCommandParser :
deactivate DeleteMenuCommand

DeleteMenuCommandParser --> DeleteCommandParser : d
deactivate DeleteMenuCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
DeleteMenuCommandParser -[hidden]-> DeleteCommandParser
destroy DeleteMenuCommandParser

DeleteCommandParser --> AddressBookParser : d
deactivate DeleteCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
DeleteCommandParser -[hidden]-> AddressBookParser
destroy DeleteCommandParser

AddressBookParser --> LogicManager : d
deactivate AddressBookParser

LogicManager -> DeleteMenuCommand : execute(m)
activate DeleteMenuCommand

DeleteMenuCommand -> Model : deleteProduct(id)
activate Model

Model --> DeleteMenuCommand
deactivate Model

create CommandResult
DeleteMenuCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteMenuCommand
deactivate CommandResult

DeleteMenuCommand --> LogicManager : r
deactivate DeleteMenuCommand

[<--LogicManager
deactivate LogicManager
@enduml
33 changes: 33 additions & 0 deletions docs/diagrams/DeleteMenuSequenceDiagram-Model.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
participant ":AddressBook" as AddressBook MODEL_COLOR
end box

box ProductMenu
participant ":ProductMenu" as ProductMenu
end box

[-> Model : deleteProduct(id)
activate Model

Model -> AddressBook : deleteProduct(id)
activate AddressBook

AddressBook -> ProductMenu :deleteProduct(id)
activate ProductMenu

ProductMenu -> ProductMenu :deleteProduct(id)
ProductMenu -> AddressBook
deactivate ProductMenu

AddressBook --> Model :
deactivate AddressBook

[<-- Model
deactivate Model

@enduml
Binary file added docs/images/AddMenuSequenceDiagram-Logic.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/AddMenuSequenceDiagram-Model.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/DeleteMenuSequenceDiagram-Logic.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/DeleteMenuSequenceDiagram-Model.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 f6b796f

Please sign in to comment.