Skip to content

Commit

Permalink
Merge pull request #343 from NaychiMin/Update-DG-with-changes-made-v2.1
Browse files Browse the repository at this point in the history
Task 342, Update DG, UG and PPP
  • Loading branch information
ziyi105 authored Nov 13, 2023
2 parents 5ed0008 + 296f71d commit 237419d
Show file tree
Hide file tree
Showing 20 changed files with 376 additions and 82 deletions.
2 changes: 1 addition & 1 deletion docs/AboutUs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Display | Name | Github Profile | Portfolio
--------|:--------:|:----------------------------------------:|:---------:
![](images/aboutUs/shanice.jpg) | Shanice | [Github](https://github.com/ShaniceTang) | [Portfolio](team/shanicetang.md)
![](https://via.placeholder.com/100.png?text=Photo) | Naychi | [Github](https://github.com/NaychiMin/tp) | [Portfolio](team/NaychiMin.md)
![](https://via.placeholder.com/100.png?text=Photo) | Naychi | [Github](https://github.com/NaychiMin/tp) | [Portfolio](team/naychimin.md)
![](https://via.placeholder.com/100.png?text=Photo) | Zi Yi | [Github](https://github.com/ziyi105) | [Portfolio](team/ziyi105.md)
![](https://via.placeholder.com/100.png?text=Photo) | Dexter Hoon | [Github](https://github.com/DextheChik3n) | [Portfolio](team/dexthechik3n.md)
![](https://via.placeholder.com/100.png?text=Photo) | Chua Zhong Heng | [Github](https://github.com/Cazh1/tp) | [Portfolio](team/cazh1.md)
82 changes: 71 additions & 11 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* [Next Day](#next-day)
* [Previous Day](#previous-day)
* [List Ingredients](#list-ingredients)
* [List Sale By Day](#list-sale-by-day)
* [Pantry-isDishCooked()](#pantry---isdishcooked)
* [Pantry-calculateMaxDish()](#pantry---calculatemaxdish)
* [Delete Dish](#delete-dish)
* [Edit Price](#edit-price)
* [Help](#help)
Expand Down Expand Up @@ -254,20 +257,77 @@ The user is also shown the receded day number.

API: [ListIngredientCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/ListIngredientCommand.java)

| No | Step | Description |
|----|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 | Initialization | The sequence begins with the `Main` class invoking the `execute` method of the `ListIngredientCommand` after parsing a user command. |
| 2-3 | Interaction with 'Menu' | The `ListIngredientCommand` communicates with the `Menu` class, invoking the `getMenuItemsList()` method to retrieve a list of menu items. The function returns an ArrayList of objects of 'Dish' type. |
| 4 | Interaction with 'Ui' | The `ListIngredientCommand` communicates with the `Ui` class, invoking the `printIngredients()` method to print out the list of ingredients used for the selected dish. <br/> * The function returns an ArrayList of objects of 'Dish' type. The `get()` method is then invoked to get the dish of the specified index. However, this is ommitted to prevent unnecessary sophistication. |
| 5-6 | Interaction with 'Dish' | The `Ui` class communicates with the `Dish` class, invoking the `getIngredients()` method to obtain the list of ingredients for the selected dish. The `Dish` class responds with an ArrayList of objects of 'Ingredient' type to the `Ui` class. |
| 7-8 | Iteration through Ingredients | There is a loop that iterates through each ingredient in the list. The `Ui` class interacts with the `Ingredients` class, converting each ingredient to a string containing the ingredient and quantity needed. |
| 9-10 | Display to User | The `Ui` class showcases the information to the user through the `showToUser()` method. |
The diagram above omits the showToUser() function in the Ui class to prevent unnecessary sophistication.
Although it may seem tedious the steps are essentially as listed below:
- The sequence begins with the `Main` class invoking the `execute` method of the `ListIngredientCommand` after using a parser command.
- The `ListIngredientCommand` communicates with the `Menu` class, invoking the `getMenuItemsList()` method to retrieve a list of menu items. The function returns an ArrayList of objects of 'Dish' type.
- The `ListIngredientCommand` communicates with the `Ui` class, invoking the `showListIngredients()` method to print out the list of ingredients used for the selected dish.
- The `Ui` class communicates with the `Dish` class, invoking the `getIngredients()` method to obtain the list of ingredients for the selected dish. The `Dish` class responds with an ArrayList of objects of 'Ingredient' type to the `Ui` class.
- There is a loop that iterates through each ingredient in the list. The `Ui` class interacts with the `Ingredients` class, to obtain the name, quantity and unit of the ingredient.
- The `Ui` class showcases the information to the user through the `formatListIngredient()` method.

### List Sale By Day
![List_Sale Execution](images/sequence/ShowSaleByDayCommand_execute.png)


*Figure 14: Execution of list_sale command*

API: [ListSaleByDay.java]({repoURL}src/main/java/seedu/cafectrl/command/ListSaleByDayCommand.java)

The diagram above omits the showToUser() function in the Ui class to prevent unnecessary sophistication.
The steps are essentially as listed below:
- The sequence starts with the invocation of the `execute()` method in the `ListSaleByDayCommand` class, which the invokes the `sales.printSaleByDay()` method.
- The `Sales` class interacts with the `OrderList` class to check if there are completed orders to be displayed.
- If there are no completed orders or no orders at all, a message is shown to the user via the `Ui` class and the command's execution ends.
- If there are completed orders, the process continues to display it in a table format.
- `showSalesTop()`: Display table header
- `orderList.printOrderList()`: The OrderList iterates over each order, aggregates orders, and prints details for each aggregated order. For each aggregated order, details like dish name, quantity, and total order cost are retrieved from the Order class and shown to the user via the Ui class.
- `showSalesCost()`: Displays the total sales cost for the aggregated orders.
- `showSalesBottom()`: Displays the bottom of the table

* The List Total Sales command follows a comparable sequence, and as such, it will be excluded to avoid the repetition of multiple similar diagrams.

### Pantry - isDishCooked()
![isDishCooked_function](images/sequence/Pantry_IsDishCooked.png)


*Figure 15: Data processing of `isDishCooked()` function used in add_order command*

API: [Pantry.java]({repoURL}src/main/java/seedu/cafectrl/data/Pantry.java)

This section briefly explains how `add_order` checks if the order added is successfully cooked.
The steps are essentially as listed below:
- The sequence starts with the invocation of `isDishCooked()` to the `Pantry` class, with a list of ingredients needed for the order.
- For each ingredient in the dish, `isDishCooked()` first obtains the quantity of the ingredients needed (`usedQty`) for the order as shown in step 4 and 5.
- The function then attempts to get the Ingredient used from the current stock in the Pantry (`stockQty`) as shown in steps 11 and 12.
- If `usedIngredientFromStock` is null, it means that the ingredient does not exist in the Pantry and the sequence ends with a `false` being returned.
- If `usedIngredientFromStock` exists but the quantity is insufficient,
- If `usedIngredientFromStock` is found and the quantity is sufficient, the used quantity is deducted from the stock quantity in the Pantry and the sequence ends with a `true` being returned.
- A `false` indicates that the order was unsuccessful while a `true` indicates that the order was successful.

### Pantry - calculateMaxDish()
![calculateMaxDish_function](images/sequence/Pantry_CalculateMaxDish.png)


*Figure 16: Data processing of `calculateMaxDish()` function used in add_order command*

API: [Pantry.java]({repoURL}src/main/java/seedu/cafectrl/data/Pantry.java)

This section briefly explains how `add_order` checks if restocking of ingredients is needed.
The steps are essentially as listed below:
- The sequence starts with the invocation of `calculateMaxDish()` to the `Pantry` class.
- Steps 2 to 6 involves retrieving the ingredients used to make the dish.
- The function `calculateMaxDishForEachIngredient` returns an integer and assigns it to the variable `numOfDish` which is the maximum number of dishes that can be cooked.
- If the order is incomplete
- ingredients that need restocking will be passed into the `handleRestock` function.
- If the order is complete,
- ingredients that are unable to prep the next dish will be passed into the `handleRestock` function.

### Delete Dish

![Delete Dish Execution](images/sequence/DeleteDishCommand_execute.png)

*Figure 14: Execution of delete dish command*
*Figure 17: Execution of delete dish command*

API: [DeleteDishCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/DeleteDishCommand.java)

Expand All @@ -285,7 +345,7 @@ This sequence of actions orchestrates the flow of information and operations bet

![Edit Price Execution](images/sequence/EditPriceCommand_execute.png)

*Figure 15: Execution of edit_price command*
*Figure 18: Execution of edit_price command*

API: [EditPriceCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/EditPriceCommand.java)

Expand All @@ -295,7 +355,7 @@ When the `execute()` method of `EditPriceCommand` is invoked in `Main`, it subse

![Help Execution](images/sequence/HelpCommand_execute.png)

*Figure 16: Execution of help command*
*Figure 19: Execution of help command*

API: [HelpCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/HelpCommand.java)

Expand Down
9 changes: 5 additions & 4 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ Example:
### Listing ingredients needed for the selected dish : `list_ingredients`
Lists out the ingredients needed along with the quantity for a specific dish

Format: `list_ingredients DISH_INDEX`
Format: `list_ingredients index/DISH_INDEX`

Example:
- list followed by list_ingredients 1 lists the ingredients of the 1st dish on the menu
- list followed by list_ingredients index/1 lists the ingredients of the 1st dish on the menu
```
+-------------------------------------------------------+
|Dish: chicken rice |
Expand Down Expand Up @@ -317,7 +317,8 @@ Format: `list_total_sales`
Example: `list_total_sales`

Output:
- `show_sales` lists the dishes sold along with the total sales for every operating day of the cafe.
- list_total_sales lists the dishes sold along with the total sales for every operating day of the cafe.

```
+---------------------------------------------------------------------------+
Day 1:
Expand Down Expand Up @@ -411,7 +412,7 @@ Format: `bye`
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Add** | `add name/DISH_NAME price/PRICE ingredient/INGREDIENT1_NAME qty/INGREDIENT1_QTY [, ingredient/INGREDIENT2_NAME qty/INGREDIENT2_QTY, ...]`<br><br/>Example:<br/>`add name/chicken rice price/3.00 ingredient/rice qty/50g, ingredient/chicken qty/100g` |
| **List Menu** | `list_menu` |
| **List Ingredients** | `list_ingredients DISH_INDEX`<br><br/>Example:<br>`list_ingredients 1` |
| **List Ingredients** | `list_ingredients index/DISH_INDEX`<br><br/>Example:<br>`list_ingredients index/1` |
| **Delete** | `delete DISH_INDEX`<br><br/>Example:<br>`delete 1` |
| **Edit Price** | `edit_price index/DISH_INDEX price/NEW_PRICE`<br><br/>Example:<br>`edit_price index/1 price/4.50` |
| **List Sale** | `list_total_sales` |
Expand Down
78 changes: 49 additions & 29 deletions docs/diagrams/sequence/ListIngredientCommand_execute.puml
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
@startuml
!define COMMAND class ListIngredientCommand
!define UI class Ui
!define MENU class Menu
!define DISH class Dish
!define COMMAND class ":ListIngredientCommand"
!define UI class ":Ui"
!define MENU class ":Menu"
!define DISH class ":Dish"
!define PARSER class Parser

autonumber
-> ListIngredientCommand: execute()

activate ListIngredientCommand
ListIngredientCommand -> Menu : getMenuItemsList()
activate Menu
Menu --> ListIngredientCommand: selectedDish : Dish
deactivate Menu
-> ":ListIngredientCommand": execute()

activate ":ListIngredientCommand"
":ListIngredientCommand" -> ":Menu" : getMenuItemsList()
activate ":Menu"
":Menu" --> ":ListIngredientCommand": selectedDish : ":Dish"
deactivate ":Menu"

":ListIngredientCommand" -> ":Ui" : showListIngredientsMessage(selectedDish: Dish)
activate ":Ui"

":Ui" -> ":Ui" : showDishName(dish: Dish)
activate ":Ui"
":Ui" -> ":Dish" : dish.getName()
activate ":Dish"
return : String
return

":Ui" -> ":Ui" : showIngredientList(dish : Dish)
activate ":Ui"

":Ui" -> ":Dish" : selectedDish.getIngredients()
activate ":Dish"
return ingredients: ArrayList<Ingredient>

ListIngredientCommand -> Ui : printIngredients(selectedDish: Dish)
activate Ui
Ui -> Dish : selectedDish.getIngredients()
activate Dish
Dish --> Ui : ingredients: Ingredient
deactivate Dish


loop ingredients
Ui -> Ingredients: ingredient.toString()
activate Ingredients
Ingredients --> Ui
deactivate Ingredients
":Ui" -> ":Ingredients": ingredient.getName()
activate ":Ingredients"
":Ingredients" --> ":Ui" :String
deactivate ":Ingredients"
":Ui" -> ":Ingredients": ingredient.getQty()
activate ":Ingredients"
":Ingredients" --> ":Ui" :int
deactivate ":Ingredients"
":Ui" -> ":Ingredients": ingredient.getUnit()
activate ":Ingredients"
":Ingredients" --> ":Ui" :String
deactivate ":Ingredients"
":Ui" -> ":Ui" : formatListIngredient(ingredientName: String, ingredientAmount: String)
activate ":Ui"
return
end loop

Ui -> Ui: showToUser(message: String)
activate Ui
Ui --> Ui
deactivate Ui
Ui --> ListIngredientCommand
deactivate Ui
deactivate ListIngredientCommand
<-- ListIngredientCommand
":Ui" -> ":Ui": showIngredientsEndCap()
activate ":Ui"
return
return
return

@enduml
@enduml
74 changes: 74 additions & 0 deletions docs/diagrams/sequence/ListSalesByDayCommand.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@startuml
!define COMMAND class ":ListSaleByDayCommand"
!define SALES class ":Sales"
!define ORDERLIST class ":OrderList"
!define ORDER class ":Order"
!define UI class ":Ui"

autonumber

-> ":ListSaleByDayCommand": execute()

activate ":ListSaleByDayCommand"
":ListSaleByDayCommand" -> ":Sales": sales.printSaleByDay(ui: ":Ui", menu: Menu, day: int)
activate ":Sales"
":Sales" -> ":OrderList": orderList.hasCompleteOrders()

activate ":OrderList"
return :boolean

alt no complete order || no orders
":Sales" -> ":Ui" : showToUser(message: String)
activate ":Ui"
return
":Sales" --> ":ListSaleByDayCommand"
<-- ":ListSaleByDayCommand"
end alt

":Sales" -> ":Ui": showSalesTop()
activate ":Ui"
return
":Sales" -> ":OrderList": orderList.printOrderList()
activate ":OrderList"

loop order
":OrderList" -> ":OrderList": aggregateOrders()
activate ":OrderList"
return
end loop

loop aggregatedOrder
":OrderList" -> ":Order" **:
activate ":Order"
return aggregatedOrder: ":Order"
":OrderList" -> ":Order": aggregatedOrder.getDishName()
activate ":Order"
return :String
":OrderList" -> ":Order": aggregatedOrder.getQty()
activate ":Order"
return :String
":OrderList" -> ":Order": aggregatedOrder.getTotalOrderCost()
activate ":Order"
return :float
destroy ":Order"
":OrderList" -> ":Ui": showSalesAll(dishName: String, dishQty: int, dishPrice: String)
activate ":Ui"
":Ui" -> ":Ui": formatShowSales(dishName: String, dishQty: int, dishPrice: String)
activate ":Ui"
return
return
end loop
":OrderList" -> ":Ui": showSalesBottom()
activate ":Ui"
return
":OrderList" -> ":Ui": showSalesCost()
activate ":Ui"
return
":OrderList" -> ":Ui": showSalesBottom()
activate ":Ui"
return
return
return
return

@enduml
52 changes: 52 additions & 0 deletions docs/diagrams/sequence/PantryCalculateMaxDish.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@startuml
!define FUNCTION class calculateMaxDish
!define PANTRY class ":Pantry"
!define INGREDIENT class ":Ingredient"
!define DISH class ":Dish"

autonumber

-> ":Pantry": calculateMaxDish(dish: ":Dish", menu: Menu, order: Order)
activate ":Pantry"

":Pantry" -> ":Dish" : dish.getName()
activate ":Dish"
return dishName:String

":Pantry" -> ":Pantry" : retrieveIngredientsForDish(dishName: String)
activate ":Pantry"
return dishIngredients: ArrayList<":Ingredient">

loop dishIngredients
":Pantry" -> ":Ingredient" **:
activate ":Ingredient"
return dishIngredient: ":Ingredient"

":Pantry" -> ":Pantry" : calculateMaxDishForEachIngredient(dishIngredient: Ingredient)
activate ":Pantry"
return numOfDish: int

alt !order.getIsComplete()
":Pantry" -> ":Pantry" : handleIncompleteDishCase(dishIngredient: Ingredient), order: Order, numOfDish: int)
activate ":Pantry"

alt lacking ingredients (numOfDish < orderQty)
":Pantry" -> ":Pantry": handleRestock(dishIngredient: ":Ingredient", orderQty: int)
activate ":Pantry"
return
end alt
return

else order.getIsComplete()
":Pantry" -> ":Pantry" : handleZeroDishCase(dishIngredient: Ingredient), order: Order, numOfDish: int)
activate ":Pantry"
alt lacking ingredients (numOfDish == 0)
":Pantry" -> ":Pantry": handleRestock(dishIngredient: ":Ingredient", orderQty: int)
activate ":Pantry"
return
end alt
return
end loop
return maxNumOfDish: int

@enduml
Loading

0 comments on commit 237419d

Please sign in to comment.