forked from nus-cs2113-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from NaychiMin/189_print_orderlist
Task 189, implement function to show total sales for all days and sales by specific days.
- Loading branch information
Showing
19 changed files
with
531 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1 | chicken rice | 2 | 4.0 | true | ||
1 | chicken roast | 2 | 4.0 | true | ||
1 | chicken roast | 2 | 4.0 | true | ||
2 | chicken rice | 2 | 4.0 | true | ||
2 | chicken roast | 2 | 4.0 | true | ||
2 | chicken roast | 8 | 16.0 | false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/seedu/cafectrl/command/ShowSalesByDayCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package seedu.cafectrl.command; | ||
|
||
import seedu.cafectrl.data.Menu; | ||
import seedu.cafectrl.data.Sales; | ||
import seedu.cafectrl.ui.Ui; | ||
|
||
public class ShowSalesByDayCommand extends Command { | ||
public static final String COMMAND_WORD = "show_sale"; | ||
|
||
private final int day; | ||
private final Ui ui; | ||
private final Sales sales; | ||
private final Menu menu; | ||
|
||
public ShowSalesByDayCommand(int day, Ui ui, Sales sales, Menu menu) { | ||
this.day = day; | ||
this.ui = ui; | ||
this.sales = sales; | ||
this.menu = menu; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
sales.printSaleByDay(ui, menu, day); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/seedu/cafectrl/command/ShowSalesCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package seedu.cafectrl.command; | ||
|
||
import seedu.cafectrl.data.Menu; | ||
import seedu.cafectrl.data.Sales; | ||
import seedu.cafectrl.ui.Ui; | ||
|
||
public class ShowSalesCommand extends Command { | ||
public static final String COMMAND_WORD = "show_sales"; | ||
private Sales sales; | ||
private Ui ui; | ||
private Menu menu; | ||
|
||
public ShowSalesCommand(Sales sales, Ui ui, Menu menu) { | ||
this.sales = sales; | ||
this.ui = ui; | ||
this.menu = menu; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
sales.printSales(ui, menu); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
package seedu.cafectrl.data; | ||
|
||
import seedu.cafectrl.ui.Messages; | ||
import seedu.cafectrl.ui.Ui; | ||
|
||
import java.text.DecimalFormat; | ||
|
||
public class Chef { | ||
private final Order order; | ||
private final Pantry pantry; | ||
private final Ui ui; | ||
private Menu menu; | ||
private final DecimalFormat dollarValue = new DecimalFormat("0.00"); | ||
|
||
public Chef(Order order, Pantry pantry, Ui ui) { | ||
public Chef(Order order, Pantry pantry, Ui ui, Menu menu) { | ||
this.order = order; | ||
this.pantry = pantry; | ||
this.ui = ui; | ||
this.menu = menu; | ||
} | ||
|
||
public void cookDish() { | ||
try { | ||
if (!order.getIsComplete()) { | ||
ui.showChefMessage(); | ||
pantry.decreaseIngredientsStock(order.getIngredientList()); | ||
order.setComplete(); | ||
boolean isComplete = pantry.isDishCooked(order.getIngredientList()); | ||
order.setComplete(isComplete); | ||
} | ||
ui.showToUser("Is order completed?: " + order.getIsComplete()); | ||
String orderStatus = order.getIsComplete()? Messages.COMPLETE_ORDER : Messages.INCOMPLETE_ORDER; | ||
String totalCost = dollarValue.format(order.getTotalOrderCost()); | ||
ui.showOrderStatus(orderStatus, totalCost); | ||
pantry.calculateDishAvailability(menu); | ||
} catch (Exception e) { | ||
ui.showToUser("Unable to cook: " + e.getMessage()); | ||
ui.showToUser(e.getMessage()); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.