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

Task 94, Fixed minor bugs and add in clearer error messages. #202

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

public class ShowSalesByDayCommand extends Command {
public static final String COMMAND_WORD = "show_sale";
public static final String MESSAGE_USAGE = "To show sales for a chosen day:\n "
+ "Command Format:" + COMMAND_WORD + " day/DAY_TO_DISPLAY\n"
+ "Example: " + COMMAND_WORD + " day/1";

private final int day;
private final Ui ui;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/cafectrl/command/ShowSalesCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

public class ShowSalesCommand extends Command {
public static final String COMMAND_WORD = "show_sales";
public static final String MESSAGE_USAGE = "To show sales for all days:\n" + COMMAND_WORD;
private Sales sales;
private Ui ui;
private Menu menu;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/seedu/cafectrl/data/Pantry.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you want to change inside the for loops to prevent arrowhead code

Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ public boolean isDishCooked(ArrayList<Ingredient> dishIngredients) {
//for each ingredient that is used in the dish, update the stock of ingredient left.
for (Ingredient dishIngredient : dishIngredients) {
Ingredient usedIngredientFromStock = getIngredient(dishIngredient);
if (usedIngredientFromStock == null) {
return false;
}
int stockQuantity = usedIngredientFromStock.getQty();
int usedQuantity = dishIngredient.getQty();
int finalQuantity = stockQuantity-usedQuantity;
if(finalQuantity < 0) {
int finalQuantity = stockQuantity - usedQuantity;
if (finalQuantity < 0) {
return false;
}
usedIngredientFromStock.setQty(finalQuantity);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/cafectrl/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ private static Command prepareShowSalesByDay(String arguments, Ui ui, Sales sale
Matcher matcher = showSaleByDayPattern.matcher(arguments.trim());

if (!matcher.matches()) {
return new IncorrectCommand(ErrorMessages.INVALID_SHOW_SALE_DAY_FORMAT_MESSAGE, ui);
return new IncorrectCommand(ErrorMessages.INVALID_SHOW_SALE_DAY_FORMAT_MESSAGE
+ ShowSalesByDayCommand.MESSAGE_USAGE, ui);
}

try {
Expand Down
Loading