diff --git a/docs/AboutUs.md b/docs/AboutUs.md index ef64a6a50e..eb707d0c7c 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -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) \ No newline at end of file diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 00f31d6bfc..656b0be869 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -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) @@ -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.
* 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) @@ -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) @@ -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) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index eb72016aa7..15f8ff22fa 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -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 | @@ -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: @@ -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, ...]`

Example:
`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`

Example:
`list_ingredients 1` | +| **List Ingredients** | `list_ingredients index/DISH_INDEX`

Example:
`list_ingredients index/1` | | **Delete** | `delete DISH_INDEX`

Example:
`delete 1` | | **Edit Price** | `edit_price index/DISH_INDEX price/NEW_PRICE`

Example:
`edit_price index/1 price/4.50` | | **List Sale** | `list_total_sales` | diff --git a/docs/diagrams/sequence/ListIngredientCommand_execute.puml b/docs/diagrams/sequence/ListIngredientCommand_execute.puml index da32337fb0..4a3ba6606a 100644 --- a/docs/diagrams/sequence/ListIngredientCommand_execute.puml +++ b/docs/diagrams/sequence/ListIngredientCommand_execute.puml @@ -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 -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 \ No newline at end of file diff --git a/docs/diagrams/sequence/ListSalesByDayCommand.puml b/docs/diagrams/sequence/ListSalesByDayCommand.puml new file mode 100644 index 0000000000..cb45a87ed0 --- /dev/null +++ b/docs/diagrams/sequence/ListSalesByDayCommand.puml @@ -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 \ No newline at end of file diff --git a/docs/diagrams/sequence/PantryCalculateMaxDish.puml b/docs/diagrams/sequence/PantryCalculateMaxDish.puml new file mode 100644 index 0000000000..40f6fe2612 --- /dev/null +++ b/docs/diagrams/sequence/PantryCalculateMaxDish.puml @@ -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 \ No newline at end of file diff --git a/docs/diagrams/sequence/PantryIsDishCooked.puml b/docs/diagrams/sequence/PantryIsDishCooked.puml new file mode 100644 index 0000000000..716042d9cf --- /dev/null +++ b/docs/diagrams/sequence/PantryIsDishCooked.puml @@ -0,0 +1,50 @@ +@startuml +!define FUNCTION class isDishCooked +!define PANTRY class ":Pantry" +!define INGREDIENT class ":Ingredient" +!define DISH class Dish + +autonumber + + -> ":Pantry": isDishCooked(dishIngredients: ArrayList) + activate ":Pantry" + + loop dishIngredients + ":Pantry" -> ":Ingredient" **: + activate ":Ingredient" + ":Ingredient" --> ":Pantry": ingredient: ":Ingredient" + deactivate ":Ingredient" + + ":Pantry" -> ":Ingredient": getQty() + activate ":Ingredient" + return usedQty: int + + ":Pantry" -> ":Pantry": getIngredient(dishIngredient: Ingredient)) + activate ":Pantry" + return :":Ingredient" + + ":Pantry" -> ":Ingredient" **: + activate ":Ingredient" + return usedIngredientFromStock: ":Ingredient" + + alt usedIngredientFromStock == null + <-- ":Pantry": :boolean + end alt + + ":Pantry" -> ":Ingredient": getQty() + activate ":Ingredient" + return stockQty: int + + alt not enough ":Ingredient" (stockQty-usedQty<0) + <-- ":Pantry": :boolean + end alt + ":Pantry" -> ":Ingredient" : setQty(quantity: int) + activate ":Ingredient" + return + end loop + + return :boolean + + + +@enduml \ No newline at end of file diff --git a/docs/images/sequence/ListIngredientCommand_execute.png b/docs/images/sequence/ListIngredientCommand_execute.png index 9b610d72c2..2728acb32c 100644 Binary files a/docs/images/sequence/ListIngredientCommand_execute.png and b/docs/images/sequence/ListIngredientCommand_execute.png differ diff --git a/docs/images/sequence/Pantry_CalculateMaxDish.png b/docs/images/sequence/Pantry_CalculateMaxDish.png new file mode 100644 index 0000000000..d42f54d0b4 Binary files /dev/null and b/docs/images/sequence/Pantry_CalculateMaxDish.png differ diff --git a/docs/images/sequence/Pantry_IsDishCooked.png b/docs/images/sequence/Pantry_IsDishCooked.png new file mode 100644 index 0000000000..4d94e86a61 Binary files /dev/null and b/docs/images/sequence/Pantry_IsDishCooked.png differ diff --git a/docs/images/sequence/ShowSaleByDayCommand_execute.png b/docs/images/sequence/ShowSaleByDayCommand_execute.png new file mode 100644 index 0000000000..a5aea8b82e Binary files /dev/null and b/docs/images/sequence/ShowSaleByDayCommand_execute.png differ diff --git a/docs/images_PPP/naychi/exampleOfBugReport.png b/docs/images_PPP/naychi/exampleOfBugReport.png new file mode 100644 index 0000000000..63ea3168ca Binary files /dev/null and b/docs/images_PPP/naychi/exampleOfBugReport.png differ diff --git a/docs/team/NaychiMin.md b/docs/team/NaychiMin.md index 66637415c6..8b007f94cb 100644 --- a/docs/team/NaychiMin.md +++ b/docs/team/NaychiMin.md @@ -15,7 +15,7 @@ Café proprietors who prefer typing on CLI than any other interaction method and ## Summary of Contributions ### Code Contribution -[Follow here to see code written by me](https://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=functional-code~test-code~docs&since=2023-09-22&tabOpen=true&tabType=authorship&zFR=false&tabAuthor=NaychiMin&tabRepo=AY2324S1-CS2113-T17-2%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=functional-code~test-code~docs&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false) +[Click here to see my code contribution!](https://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=functional-code~test-code~docs&since=2023-09-22&tabOpen=true&tabType=authorship&zFR=false&tabAuthor=NaychiMin&tabRepo=AY2324S1-CS2113-T17-2%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=functional-code~test-code~docs&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false) ### Enhancements implemented @@ -23,7 +23,7 @@ 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_OF_DISH_TO_LIST` + - 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. @@ -32,6 +32,9 @@ Café proprietors who prefer typing on CLI than any other interaction method and 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. 3. **Show Sale By Day** - Function: Allow the user to view the sale for the desired day.
- Command Format: `list_sale day/DAY_TO_LIST`
@@ -42,9 +45,9 @@ Café proprietors who prefer typing on CLI than any other interaction method and - Specific error messages will then be output to user along with recommended command format. 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 handle the logic of the data being processed after an order was added to an orderList for the following purposes: - - Determine if the order can be completed - - Determine which ingredients need to be restocked + - 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. #### Enhancements @@ -53,16 +56,31 @@ Café proprietors who prefer typing on CLI than any other interaction method and - ShaniceTang focused on the buying and restocking of pantry ingredients, as detailed in her PPP. - My role, outlined in point 4 above, involved implementing key functions, including: - `isDishCooked`: - - Returns a boolean, indicating the success of the order. - - Manages the decrease and update of ingredient quantities in the Pantry Stock. + - 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. - `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. - `calculateMaxDishes`: - Handles the logic for calculating the number of dishes made. - - Manages the logic for determining restocked ingredients and their required quantities. - - Presents the information neatly in a table for the user. - - Initially unfamiliar with OOP concepts, this class's creation, which interacts with various classes (menu, order, chef, dish, and ingredients), presented a challenging learning opportunity. - - Explored the use of Java stream filter, a concept introduced in lectures. + - 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. + - 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: @@ -89,11 +107,25 @@ Café proprietors who prefer typing on CLI than any other interaction method and 3. List Sale by day ### Contributions to DG -1. Worked on ShaniceTang with the following: - - Architecture diagram and overall description of the architecture - - Sequence diagram of interactions of various components shown in the architecture diagram - - Data Component class diagram and description -2. List Ingredient +[DeveloperGuide](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html) +1. Worked with ShaniceTang on the following: + - [Architecture diagram](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#architecture) and overall description of the architecture. + - Sequence diagram of [interactions of various components](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#how-the-architecture-components-interact-with-each-other) shown in the architecture diagram + - Drafting data Component class diagram and [description](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#data-component) +2. [List Ingredient](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#list-ingredients) +3. [List Sale By Day](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#list-sale-by-day) +4. [Pantry - isDishCooked()](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#pantry---isdishcooked) +5. [Pantry - calculateMaxDish()](https://ay2324s1-cs2113-t17-2.github.io/tp/DeveloperGuide.html#pantry---calculatemaxdish) ### Other Contributions to Team-based Task -1. Maintain issue tracker +1. Maintaining the issue tracker +2. Testing of application and reporting bugs found. + - example: ![Relevant Telegram screenshot](../images_PPP/naychi/exampleOfBugReport.png) + +### Review / Mentoring Contributions +1. Reviewed and merged some PRs such as [#313](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/313), ... +2. Consulting the group when clarification is needed and actively participating in weekly meetings. + +### Contributions Beyond the Project Team +1. Reported bugs in other teams' application: [#157](https://github.com/AY2324S1-CS2113T-W11-2/tp/issues/157), [#141](https://github.com/AY2324S1-CS2113T-W11-2/tp/issues/141), [#172](https://github.com/AY2324S1-CS2113T-W11-2/tp/issues/172), [#145](https://github.com/AY2324S1-CS2113T-W11-2/tp/issues/145) +2. Reviewed other groups tp PRs : [#11](https://github.com/nus-cs2113-AY2324S1/tp/pull/11/files) diff --git a/src/main/java/seedu/cafectrl/data/OrderList.java b/src/main/java/seedu/cafectrl/data/OrderList.java index f38bb3ef81..6be9faa622 100644 --- a/src/main/java/seedu/cafectrl/data/OrderList.java +++ b/src/main/java/seedu/cafectrl/data/OrderList.java @@ -68,6 +68,7 @@ public void printOrderList(Menu menu, Ui ui) { ui.showSalesBottom(); ui.showSalesCost("Total for day: ", "$" + dollarValue.format(calculateTotalCost(aggregatedOrders))); + ui.showSalesBottom(); } /** diff --git a/src/main/java/seedu/cafectrl/data/Pantry.java b/src/main/java/seedu/cafectrl/data/Pantry.java index 121f68037b..0ba78c86b2 100644 --- a/src/main/java/seedu/cafectrl/data/Pantry.java +++ b/src/main/java/seedu/cafectrl/data/Pantry.java @@ -11,7 +11,7 @@ import java.util.logging.Logger; public class Pantry { - + public static final int DEFAULT_ORDER_QTY = 1; private static Logger logger = Logger.getLogger(CafeCtrl.class.getName()); private ArrayList pantryStock; private Ui ui; @@ -175,12 +175,11 @@ public int calculateMaxDishes(Dish dish, Menu menu, Order order) { if (!order.getIsComplete()) { isRestockHeaderDisplayed = showRestockHeaderIfNeeded(isRestockHeaderDisplayed); - handleIncompleteDishCase(dishIngredient, order); + handleIncompleteDishCase(dishIngredient, order, numOfDish); } else { - if (numOfDish == 0) { - isRestockHeaderDisplayed = showRestockHeaderIfNeeded(isRestockHeaderDisplayed); - } - handleZeroDishCase(dishIngredient); + isRestockHeaderDisplayed = (numOfDish == 0) ? showRestockHeaderIfNeeded(isRestockHeaderDisplayed) + : isRestockHeaderDisplayed; + handleZeroDishCase(dishIngredient, numOfDish); } } @@ -195,15 +194,15 @@ private boolean showRestockHeaderIfNeeded(boolean isRestockHeaderDisplayed) { return isRestockHeaderDisplayed; } - private void handleIncompleteDishCase(Ingredient dishIngredient, Order order) { + private void handleIncompleteDishCase(Ingredient dishIngredient, Order order, int numOfDish) { int orderQuantity = order.getQuantity(); - if (calculateMaxDishForEachIngredient(dishIngredient) < orderQuantity) { + if (numOfDish < orderQuantity) { handleRestock(dishIngredient, orderQuantity); } } - private void handleZeroDishCase(Ingredient dishIngredient) { - if (calculateMaxDishForEachIngredient(dishIngredient) == 0) { - handleRestock(dishIngredient, 1); + private void handleZeroDishCase(Ingredient dishIngredient, int numOfDish) { + if (numOfDish == 0) { + handleRestock(dishIngredient, DEFAULT_ORDER_QTY); } } diff --git a/src/main/java/seedu/cafectrl/data/Sales.java b/src/main/java/seedu/cafectrl/data/Sales.java index b3cd9316a2..c6cc37a096 100644 --- a/src/main/java/seedu/cafectrl/data/Sales.java +++ b/src/main/java/seedu/cafectrl/data/Sales.java @@ -67,19 +67,18 @@ public void printSales(Ui ui, Menu menu) { ui.showToUser("No sales made."); return; } - //ui.showSalesBottom(); + for (int day = 0; day < orderLists.size(); day++) { logger.info("Printing sales for day " + day + "..."); OrderList orderList = orderLists.get(day); if (orderList.isEmpty() || !orderList.hasCompletedOrders()) { - ui.showToUser("", "No sales for day " + (day + DAY_DISPLAY_OFFSET) + ".", ""); + ui.showToUser("No sales for day " + (day + DAY_DISPLAY_OFFSET) + "."); continue; } ui.showSalesTop(day + DAY_DISPLAY_OFFSET); orderList.printOrderList(menu, ui); - ui.showSalesBottom(); } } @@ -102,7 +101,6 @@ public void printSaleByDay(Ui ui, Menu menu, int day) { ui.showSalesTop(day); orderList.printOrderList(menu, ui); - ui.showSalesBottom(); } catch (Exception e) { logger.log(Level.WARNING, "Unable to print sales for day " + day + "\n" + e.getMessage(), e); ui.showToUser(ErrorMessages.INVALID_SALE_DAY); diff --git a/src/main/java/seedu/cafectrl/parser/Parser.java b/src/main/java/seedu/cafectrl/parser/Parser.java index 966ec58574..09427e8f75 100644 --- a/src/main/java/seedu/cafectrl/parser/Parser.java +++ b/src/main/java/seedu/cafectrl/parser/Parser.java @@ -150,7 +150,7 @@ public Command parseCommand(Menu menu, String userInput, Ui ui, return preparePreviousDay(ui, currentDate); case ListTotalSalesCommand.COMMAND_WORD: - return prepareShowSales(sales, menu, ui); + return prepareShowSales(sales, menu, ui, arguments); case ListSaleByDayCommand.COMMAND_WORD: return prepareShowSalesByDay(arguments, ui, sales, menu); @@ -781,8 +781,13 @@ private static Command prepareNextDay(Ui ui, Sales sales, CurrentDate currentDat * @param ui The Ui object for user interface interactions. * @return A ShowSalesCommand instance for viewing all sales items. */ - private static Command prepareShowSales(Sales sale, Menu menu, Ui ui) { - return new ListTotalSalesCommand(sale, ui, menu); + private static Command prepareShowSales(Sales sale, Menu menu, Ui ui, String arguments) { + if (arguments.isEmpty()) { + return new ListTotalSalesCommand(sale, ui, menu); + } else { + return new IncorrectCommand(ErrorMessages.WRONG_LIST_TOTAL_SALES_FORMAT, ui); + } + } /** diff --git a/src/main/java/seedu/cafectrl/storage/Decoder.java b/src/main/java/seedu/cafectrl/storage/Decoder.java index 1594d73833..619580062d 100644 --- a/src/main/java/seedu/cafectrl/storage/Decoder.java +++ b/src/main/java/seedu/cafectrl/storage/Decoder.java @@ -245,7 +245,6 @@ private static void decodeSalesData(String orderLine, ArrayList order orderLists.get(day).addOrder(orderedDish); } catch (Exception e) { logger.log(Level.WARNING, "Line corrupted: " + e.getMessage(), e); - System.out.println(e.getMessage()); ui.showToUser(ErrorMessages.INVALID_SALES_DATA + orderLine); } } diff --git a/src/main/java/seedu/cafectrl/storage/Encoder.java b/src/main/java/seedu/cafectrl/storage/Encoder.java index 66eb09fb9f..89a2c8dd6d 100644 --- a/src/main/java/seedu/cafectrl/storage/Encoder.java +++ b/src/main/java/seedu/cafectrl/storage/Encoder.java @@ -136,7 +136,7 @@ public static ArrayList encodeSales(Sales sales) { orderString.append((day + 1) + DIVIDER); orderString.append(order.getDishName() + DIVIDER); orderString.append(order.getQuantity() + DIVIDER); - orderString.append(order.getOrderedDish().getPrice() + DIVIDER); + orderString.append(String.format("%.2f", order.getOrderedDish().getPrice()) + DIVIDER); orderString.append(order.getIsComplete()); orderString.append(System.lineSeparator()); encodedList.add(String.valueOf(orderString)); diff --git a/src/main/java/seedu/cafectrl/ui/ErrorMessages.java b/src/main/java/seedu/cafectrl/ui/ErrorMessages.java index b318e35390..4adeb75e8a 100644 --- a/src/main/java/seedu/cafectrl/ui/ErrorMessages.java +++ b/src/main/java/seedu/cafectrl/ui/ErrorMessages.java @@ -2,6 +2,7 @@ import seedu.cafectrl.command.EditPriceCommand; import seedu.cafectrl.command.HelpCommand; +import seedu.cafectrl.command.ListTotalSalesCommand; public class ErrorMessages { public static final String INVALID_ADD_DISH_FORMAT = "Error: Incorrect format for the add command.\n"; @@ -104,5 +105,7 @@ public class ErrorMessages { + "is inaccurate and will hence be updated from %.2f to %.2f instead."; public static final String WRONG_HELP_FORMAT = "Invalid help command format!\n" + HelpCommand.MESSAGE_USAGE; + public static final String WRONG_LIST_TOTAL_SALES_FORMAT = "Invalid list_total_sales command format!\n" + + ListTotalSalesCommand.MESSAGE_USAGE; public static final String MISSING_FILEPATH = "Error in FileManager: No File Path entered"; }