Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename PPP to all small caps. #352

Merged
merged 10 commits into from
Nov 13, 2023
4 changes: 2 additions & 2 deletions docs/team/NaychiMin.md → docs/team/naychimin.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Café proprietors who prefer typing on CLI than any other interaction method and
- `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.
- Presents the information in a 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.
Expand All @@ -80,7 +80,7 @@ Café proprietors who prefer typing on CLI than any other interaction method and
- 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.
- Ensuring the accuracy of the dish management process, my role ensures a cohesive and integrated approach to order handling.

2. **Encoding of Sales**
- Implemented encoding for the Sales object, involving:
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);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/cafectrl/data/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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,20 +79,28 @@ 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 @@ -106,6 +119,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 - 1;
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