Skip to content

Commit

Permalink
Merge branch 'master' into 335-update-ug-dg-v2.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/DeveloperGuide.md
  • Loading branch information
DextheChik3n committed Nov 13, 2023
2 parents 96151da + f05609b commit 775f7cc
Show file tree
Hide file tree
Showing 40 changed files with 469 additions and 231 deletions.
40 changes: 38 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* [Pantry-calculateMaxDish()](#pantry---calculatemaxdish)
* [Delete Dish](#delete-dish)
* [Edit Price](#edit-price)
* [View Total Stock](#view-total-stock)
* [Buy Ingredient](#buy-ingredient)
* [Help](#help)
* [**Future Enhancements**](#future-enhancements)
* [Create an interface for `Pantry`](#create-an-interface-for-pantry)
Expand All @@ -36,7 +38,7 @@
* [User stories](#user-stories)
* [**Glossary**](#glossary)
<!-- TOC -->

<br>
--------------------------------------------------------------------------------------------------------------
## **Acknowledgements**

Expand Down Expand Up @@ -79,11 +81,20 @@ The bulk of the app’s work is done by the following components:

### How the architecture components interact with each other

The Sequence Diagram below shows how the components interact with each other for the scenario where the user issues the command `delete 1`.
The Sequence Diagram below shows how the components interact with each other for the scenario where the user issues the command `bye`.

![Architecture Encode Data](images/sequence/Architecture_Encode_Data.png)
<br>*Figure 2: Architecture Encode Sequence Diagram*

1. User enters the command `bye` to the `Ui`
2. `Ui` passes the command as a string through the method `receiveUserInput('bye')` in `CafeCtrl`
3. `CafeCtrl` passes the string to `Parser` through the method `parseCommand('bye')`
4. `Parser` returns a new `exitCommand` object
5. `CafeCtrl` calls the `execute()` method of `Command` and returns after execution is completed (Step 6)
6. `CafeCtrl` calls the `saveAll()` command in `Storage` before terminating the application
7. `saveMenu()`, `saveOrderList()`, and `savePantryStock` are executed within the `saveAll()` method (Steps 8 - 13)
8. Application terminates.

### Ui component
API: [Ui.java]({repoURL}src/main/java/seedu/cafectrl/ui/Ui.java)

Expand Down Expand Up @@ -340,6 +351,31 @@ API: [EditPriceCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/EditP

When the `execute()` method of `EditPriceCommand` is invoked in `Main`, it subsequently calls the `setPrice()` method on the `Dish` object to modify the price of the specific dish. Following this, the `showEditPriceMessages()` method in the `Ui` component is triggered to retrieve and display a message from `Messages` related to the successful execution of the price modification process. This sequence of actions orchestrates the flow of information and operations between the `Main`, `EditPriceCommand`, `Dish`, and `Ui` components, ensuring the seamless handling of the price editing functionality within the application.

### View Total Stock
![View Total Stock Execution](images/sequence/ViewTotalStockCommand_execute.png)

*Figure 16: Execution of view_stock command*

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

When the `execute()` method of `ViewTotalStock` is invoked, an ArrayList of Ingredients are retrieved through the method `getPantryStock`. For each ingredient in the ArrayList, `ViewTotalStock` calls `showIngredientStock` from `Ui` to print out the list of ingredients in the ArrayList.

### Buy Ingredient
![Buy Ingredient Execution](images/sequence/BuyIngredientCommand_execute.png)

*Figure 17: Execution of buy_ingredient command*

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

When the `execute()` method is invoked
1. `addIngredient` in `BuyIngredientCommand` is called
2. Looping from the **first to the last** element in an ArrayList of Ingredients called `ingredients`, `addIngredientToStock` from `Pantry` is invoked
3. First, `pantryStock` is retrieved and `getIndexOfIngredient` is called to check if the new ingredient exists in `pantryStock`
4. If ingredient exists (`ingredientIndex != -1`), `addIngredientQuantity` is called to update the quantity of the existing ingredient
5. Else, a new `ingredient` object is returned
6. Looping from the **last to the first** element in `ingredients`, the ingredient is added to the string to be printed `ingredientString` using the `buildBuyIngredientMessage` method which ignores repeated ingredients in the list
7. Finally, `ingredientString` is shown to the user through `showToUser` method of `Ui`

### Help

![Help Execution](images/sequence/HelpCommand_execute.png)
Expand Down
10 changes: 5 additions & 5 deletions docs/diagrams/ArchitectureDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rectangle {
rectangle Ui
rectangle Parser
rectangle Command
rectangle Main
rectangle CafeCtrl
rectangle Data
rectangle Storage
}
Expand All @@ -22,10 +22,10 @@ Command --> Data
Command ..> Ui
Storage --> Data
Storage ...> TextFiles
Ui <- Main
Main --> Parser
Main --> Data
Main --> Storage
Ui <- CafeCtrl
CafeCtrl --> Parser
CafeCtrl --> Data
CafeCtrl --> Storage


@enduml
78 changes: 38 additions & 40 deletions docs/diagrams/sequence/Architecture_Encode_Data.puml
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
@startuml
!define COMMAND class ListIngredientCommand
!define UI class Ui
!define MAIN class Main
!define STORAGE class Storage
!define DATA class Data
!define PARSER class Parser
!define COMMAND class Command

autonumber
Actor user

loop userInput != "bye"
user->Ui : 'delete 1'
activate Ui
Ui-> Main : userInput : String
activate Main
Main -> Parser : parseCommand()
Activate Parser
Parser -> Main : command: Command
Deactivate Parser
Main -> Command : delete.execute()
Activate Command
Command -> Data : menu.remove()
Activate Data
return
return
user -> Ui: 'bye'
Ui-> Main : userInput : String
end loop
Main->Storage : saveMenu()
Activate Storage
Storage -> Storage: encodeMenu()
Activate Storage
return
return
return
return

@enduml
@startuml
!define UI class ":Ui"
!define MAIN class ":CafeCtrl"
!define STORAGE class ":Storage"
!define DATA class ":Data"
!define PARSER class ":Parser"
!define COMMAND class ":Command"

autonumber
Actor user

user -> ":Ui": 'bye'
Activate ":Ui"
":Ui"-> ":CafeCtrl" : receiveUserInput('bye')
loop !exitCommand
Activate ":CafeCtrl"
":CafeCtrl" -> ":Parser" : parseCommand('bye')
Activate ":Parser"
return exitCommand: ":Command"
":CafeCtrl" -> ":Command" : exitCommand.execute()
Activate ":Command"
return
end loop
":CafeCtrl"->":Storage" : saveAll()
Activate ":Storage"
":Storage" -> ":Storage": saveMenu()
Activate ":Storage"
return
":Storage" -> ":Storage": saveOrderList()
Activate ":Storage"
return
":Storage" -> ":Storage": savePantryStock()
Activate ":Storage"
return
return
return

@enduml
48 changes: 48 additions & 0 deletions docs/diagrams/sequence/BuyIngredientCommand_execute.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@startuml
!define COMMAND class ":BuyIngredientCommand"
!define UI class ":Ui"
!define MENU class ":Menu"
!define PANTRY class ":Pantry"

autonumber

-> ":BuyIngredientCommand" : execute()
activate ":BuyIngredientCommand"

":BuyIngredientCommand" -> ":BuyIngredientCommand" : addIngredient()
activate ":BuyIngredientCommand"
loop i < ingredients.size()
":BuyIngredientCommand" -> ":Pantry" : addIngredientToStock(name: String, qty: int, unit: String)
activate ":Pantry"
":Pantry" -> ":Pantry" : getPantryStock()
activate ":Pantry"
return pantryStock: ArrayList<Ingredient>

":Pantry" -> ":Pantry" : getIndexOfIngredient(name: String)
activate ":Pantry"
return ingredientIndex: int
alt ingredientIndex != -1
":Pantry" -> ":Pantry" : addIngredientQuantity(qty: int, ingredientIndex: int, unit: String)
activate ":Pantry"
return ingredient: Ingredient
":Pantry" --> ":BuyIngredientCommand" : ingredient: Ingredient
else
return ingredient: Ingredient
end
end loop

loop i >= 0
":BuyIngredientCommand" -> ":BuyIngredientCommand" : buildBuyIngredientMessage(ingredient: Ingredient)
activate ":BuyIngredientCommand"
return ingredientString: String
end loop

return
":BuyIngredientCommand" -> ":Ui" : showToUser(ingredientString: String)
activate ":Ui"
return
return



@enduml
25 changes: 25 additions & 0 deletions docs/diagrams/sequence/ViewTotalStockCommand_execute.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml
!define COMMAND class ":ViewTotalStockCommand"
!define UI class ":Ui"
!define PANTRY class ":Pantry"

autonumber

-> ":ViewTotalStockCommand" : execute()
activate ":ViewTotalStockCommand"

":ViewTotalStockCommand" -> ":Pantry" : getPantryStock().get(dishIndexToBeDeleted: int)
activate ":Pantry"
return (pantryStock: ArrayList<Ingredients>)
loop Ingredient ingredient : pantryStock
":ViewTotalStockCommand" -> ":Ui" : showIngredientStock(name: String, qty: int, unit: String)
activate ":Ui"
":Ui" -> ":Ui" : showToUser(message: String)
activate ":Ui"
return
return
end loop
return


@enduml
Binary file modified docs/images/ArchitectureDiagram.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 modified docs/images/aboutUs/shanice.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/sequence/Architecture_Encode_Data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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_PPP/shanice/bug_reporting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 9 additions & 34 deletions docs/team/NaychiMin.md → docs/team/naychimin.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,19 @@ Café proprietors who prefer typing on CLI than any other interaction method and
1. **List Ingredient**
- Function: Allow the user to view the ingredients of the desired dish from the menu.
- Command Format: `list_ingredient index/INDEX_OF_DISH_TO_LIST`
- Error Handling:
- If the specified index is out of range, to prevent index out of bounds error.
- If the specified index is of a wrong argument type to prevent number format exception.
- If the specified index is empty.
- Specific error messages will then be output to user along with recommended command format.
- Error Handling: If the specified index is out of range, of a wrong argument type or is empty.
2. **List Total Sales**
- Function: Allow the user to view the sale for each day across every day since the cafe has operated.
- Command Format: `list_total_sales`
- Error Handling:
- If the command has unnecessary arguments after the command.
- Specific error messages will then be output to user along with recommended command format.
- Error Handling: If the command has unnecessary arguments after the command.
3. **Show Sale By Day**
- Function: Allow the user to view the sale for the desired day. <br>
- Command Format: `list_sale day/DAY_TO_LIST` <br>
- Error Handling:
- If the specified index is out of range, to prevent index out of bounds error.
- If the specified index is of a wrong argument type to prevent number format exception.
- If the specified index is empty or the argument tag is missing.
- Specific error messages will then be output to user along with recommended command format.
- Error Handling: If the specified index is out of range, of a wrong argument type, is empty or the argument tag is missing.
4. **Data processing of 'add_order'**
- My group mate (Cazh1) did the parsing of the command, along with the implementation of needed classes such as Order, OrderList and Chef.
- My role was to seamlessly handle the logic of the data being processed after an order was added to an orderList for the following purposes:
- Order completion determination
- Restocking ingredient identification
- This will be elaborated on in the section below.
- Order completion determination and Restocking ingredient identification

#### Enhancements
1. **Pantry Class**
Expand All @@ -57,44 +45,31 @@ Café proprietors who prefer typing on CLI than any other interaction method and
- My role, outlined in point 4 above, involved implementing key functions, including:
- `isDishCooked`:
- Implemented to determine the success of an order.
- Returns a boolean, indicating the success of the order.
- Manages the process of retrieving necessary ingredients from the `Menu` class, along with the retrieval of the quantity of ingredients in the current `Pantry` class.
- Decreasing and updating the correct ingredient quantities in the Pantry Stock and not mixing it with the ingredients in the `Menu` class.
- The accurate execution of this function is crucial for the overall success of order processing
- which also affects other operations of the cafe, such as the amount of total sales to be displayed to users.
- The accurate execution of this function is crucial for the overall success of order processing as it affects other operations of the cafe, such as the amount of total sales to be displayed to users.
- `calculateDishAvailability`:
- Informs the user of the available quantity for each dish in the menu after each order.
- Provides essential insights into the real-time status of dish availability, alerting users of the availability of each dish in the menu
- Enables the target user(cafe manager) to keep track of dish availability and stay alerted of the dishes that are unavailable for the next order following an order being marked as successful.
- Provides essential insights into the real-time status of dish availability, alerting users of the availability of each dish in the menu.
- `calculateMaxDishes`:
- Handles the logic for calculating the number of dishes made.
- Manages the complex logic for determining restocked ingredients and their required quantities.
- Presents the information in a structured table format for user clarity and comprehension.
- Pantry Class Development:
- Creating the Pantry class was a significant learning opportunity, especially given my initial unfamiliarity with Object-Oriented Programming (OOP) concepts.
- Developing the Pantry class presented a dual challenge – not only did I navigate a crucial learning curve of OOP, but I also ensured the modularity of functions to adhere to coding standards.
- Interacting with various classes like Menu, Order, Chef, Dish, and Ingredients, the Pantry class played a pivotal role in the seamless functioning of our project.
- Creating the Pantry class was a significant learning opportunity, especially given my initial unfamiliarity with Object-Oriented Programming (OOP) concepts. Developing the Pantry class presented a challenge as I had to navigate a crucial learning curve of OOP, and try to ensure the modularity of functions while interacting with various classes.
- The exploration of Java stream filter, a concept introduced in lectures, notably enhanced the efficiency of implemented functionality and prevented arrow-head style code.
- Order and Pantry Coordination:
- My role served as the link between the add_order and buy_ingredients commands, serving as a cohesive link that unified the data(ingredients) processing aspect of order management.
- Order Processing: Seamlessly integrating logic for order success determination and the need for Pantry's ingredient stock management.
- Pantry Stock Management: My active contribution to the Pantry class connected the use of add_order command with subsequent use of the buy_ingredients command, making it a central hub for order processing, dish availability checks, and ingredient restocking prompts.
- Dish Coordination: I ensured smooth coordination across various dish-related elements, covering determination of success of order to ingredient availability and restocking.
- Ensuring the accuracy of the dish management process, my role provided a seamless flow from adding orders to procuring required ingredients. This critical link facilitated the effective functioning of the project, ensuring a cohesive and integrated approach to order handling.

2. **Encoding of Sales**
- Implemented encoding for the Sales object, involving:
- Parsing through various attributes of the Sales object.
- Converting the data to a string with the delimiter '|'.
- Parsing through various attributes of the Sales object using the delimiter '|'.
- Storing the data in a text file.

3. **Decoding of Sales**
- Executed decoding for the Sales object, encompassing:
- Parsing through the text file and separating contents using the delimiter '|'.
- Using parsed attributes to instantiate the Sales object for use in other command classes.
- Implemented error handling during decoding:
- Nonexistent dishes are filtered out.
- Lines with missing delimiters or incorrect formatting in the text file are filtered out (collaboration with Cazh1).
- Implemented error handling during decoding: lines with missing delimiters or incorrect formatting in the text file are filtered out (collaboration with Cazh1).

4. **Parser**
- Implemented parsing and error handling for the commands listed in the section above.
Expand Down
Loading

0 comments on commit 775f7cc

Please sign in to comment.