Skip to content

Commit

Permalink
Merge pull request #352 from NaychiMin/rename-ppp
Browse files Browse the repository at this point in the history
Rename PPP to all small caps.
  • Loading branch information
ShaniceTang authored Nov 13, 2023
2 parents 4abbf3f + bc62c5b commit 648e9fe
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 54 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ListSaleByDayCommand(int day, Ui ui, Sales sales, Menu menu) {
public void execute() {
logger.info("Executing ShowSalesByDayCommand...");
try {
sales.printSaleByDay(ui, menu, day);
sales.printSaleByDay(ui, day);
} catch (Exception e) {
ui.showToUser(ErrorMessages.INVALID_SALE_DAY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public ListTotalSalesCommand(Sales sales, Ui ui, Menu menu) {
@Override
public void execute() {
logger.info("Executing ShowSalesCommand...");
sales.printSales(ui, menu);
sales.printSales(ui);
}
}
5 changes: 2 additions & 3 deletions src/main/java/seedu/cafectrl/data/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public Dish getDishFromName(String dishName) {
String formattedDishName = dishName.toLowerCase().trim();
for (int i = 0; i < getSize(); i++) {
String menuDishName = getDishFromId(i).getName();
String formattedMenuDishName = menuDishName.toLowerCase().trim();

if (formattedMenuDishName.equals(formattedDishName)){
String formattedMenuDishName = menuDishName.trim();
if (formattedMenuDishName.equalsIgnoreCase(formattedDishName)) {
return getDishFromId(i);
}
}
Expand Down
30 changes: 22 additions & 8 deletions src/main/java/seedu/cafectrl/data/OrderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ public void addCost(Order order) {
/**
* Prints the order list for a specific day, including dish names, quantities, and total cost prices.
*
* @param menu The Menu object representing the cafe's menu.
*/
public void printOrderList(Menu menu, Ui ui) {
public void printOrderList(Ui ui) {
logger.info("Printing order list...");
ArrayList<Order> aggregatedOrders = menu.getAggregatedOrders();

if (orderList.isEmpty() || !hasCompletedOrders()) {
ui.showToUser("No sales for this day.");
return;
}

ArrayList<Order> aggregatedOrders = new ArrayList<>();

for (Order order : orderList) {
aggregateOrder(order, aggregatedOrders);
Expand All @@ -74,21 +79,29 @@ public void printOrderList(Menu menu, Ui ui) {
/**
* Aggregates orders by updating quantities and total order costs for the same dish.
*
* @param order The Order object to be aggregated.
* @param order The Order object to be aggregated.
* @param aggregatedOrders The ArrayList of aggregated orders.
*/
private void aggregateOrder(Order order, ArrayList<Order> aggregatedOrders) {
logger.info("Aggregating order...");

if (order.getIsComplete()) {
int index = getIndexByDishName(aggregatedOrders, order.getDishName());
aggregatedOrders.get(index)
.setQuantity(aggregatedOrders.get(index).getQuantity() + order.getQuantity());
aggregatedOrders.get(index)
.setTotalOrderCost(aggregatedOrders.get(index).getTotalOrderCost() + order.getTotalOrderCost());
//if dish is not found in aggregated orders, add the dish into it
if (index == -1) {
aggregatedOrders.add(new Order(order.getOrderedDish(), order.getQuantity(), order.getTotalOrderCost(),
true));
} else {
//else add the quantities and totalCost accordingly
aggregatedOrders.get(index)
.setQuantity(aggregatedOrders.get(index).getQuantity() + order.getQuantity());
aggregatedOrders.get(index)
.setTotalOrderCost(aggregatedOrders.get(index).getTotalOrderCost() + order.getTotalOrderCost());
}
}
}

//@@author Shanice Tang
/**
* Finds the index of an order in the aggregated orders list based on the dish name.
*
Expand All @@ -108,6 +121,7 @@ private int getIndexByDishName(ArrayList<Order> aggregatedOrders, String dishNam
}
return -1;
}
//@@author

/**
* Calculates the total cost of all orders for a specific day.
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/seedu/cafectrl/data/Sales.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public OrderList getOrderList(int index) {
* Prints all sales data, organized by day, including dish names, quantities, and total cost prices.
*
* @param ui The Ui object for user interface interactions.
* @param menu The Menu object representing the cafe's menu.
*/
public void printSales(Ui ui, Menu menu) {
public void printSales(Ui ui) {
if(isOrderListsEmpty()) {
logger.info("Printing empty sales...");
ui.showToUser("No sales made.");
Expand All @@ -78,18 +77,17 @@ public void printSales(Ui ui, Menu menu) {
}

ui.showSalesTop(day + DAY_DISPLAY_OFFSET);
orderList.printOrderList(menu, ui);
orderList.printOrderList(ui);
}
}

/**
* Prints sales data for a specific day, including dish names, quantities, and total cost prices.
*
* @param ui The Ui object for user interface interactions.
* @param menu The Menu object representing the cafe's menu.
* @param day The day for which sales data is to be printed.
*/
public void printSaleByDay(Ui ui, Menu menu, int day) {
public void printSaleByDay(Ui ui, int day) {
logger.info("Printing sales by day...");
int orderListIndex = day - DAY_DISPLAY_OFFSET;
try {
Expand All @@ -98,9 +96,9 @@ public void printSaleByDay(Ui ui, Menu menu, int day) {
ui.showToUser("No sales for this day.");
return;
}
ui.showSalesTop(day);

orderList.printOrderList(menu, ui);
ui.showSalesTop(day);
orderList.printOrderList(ui);
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to print sales for day " + day + "\n" + e.getMessage(), e);
ui.showToUser(ErrorMessages.INVALID_SALE_DAY);
Expand Down

0 comments on commit 648e9fe

Please sign in to comment.