diff --git a/src/main/java/seedu/cafectrl/command/AddDishCommand.java b/src/main/java/seedu/cafectrl/command/AddDishCommand.java index de5742f2da..32eb1ac79a 100644 --- a/src/main/java/seedu/cafectrl/command/AddDishCommand.java +++ b/src/main/java/seedu/cafectrl/command/AddDishCommand.java @@ -12,7 +12,7 @@ public class AddDishCommand extends Command { public static final String MESSAGE_USAGE = "To add a new dish to the menu: \n" + COMMAND_WORD + " name/DISH_NAME price/DISH_PRICE ingredient/INGREDIENT1_NAME qty/INGREDIENT1_QTY" + "[, ingredient/INGREDIENT2_NAME, qty/INGREDIENT2_QTY...]\n" - + "Example:\n" + + "Example:" + COMMAND_WORD + " name/chicken rice price/3.00 ingredient/rice qty/200g, ingredient/chicken qty/100g"; protected Menu menu; diff --git a/src/main/java/seedu/cafectrl/command/AddOrderCommand.java b/src/main/java/seedu/cafectrl/command/AddOrderCommand.java index 285862ab52..b7f84ef65e 100644 --- a/src/main/java/seedu/cafectrl/command/AddOrderCommand.java +++ b/src/main/java/seedu/cafectrl/command/AddOrderCommand.java @@ -12,7 +12,7 @@ public class AddOrderCommand extends Command { public static final String COMMAND_WORD = "add_order"; public static final String MESSAGE_USAGE = "To add a new order: \n" + COMMAND_WORD - + "name/DISH_NAME qty/QUANTITY\n" + + " name/DISH_NAME qty/QUANTITY\n" + "Example: " + COMMAND_WORD + "name/chicken rice qty/2"; diff --git a/src/main/java/seedu/cafectrl/command/BuyIngredientCommand.java b/src/main/java/seedu/cafectrl/command/BuyIngredientCommand.java index d8a4fefcdf..edb3bac19b 100644 --- a/src/main/java/seedu/cafectrl/command/BuyIngredientCommand.java +++ b/src/main/java/seedu/cafectrl/command/BuyIngredientCommand.java @@ -16,7 +16,7 @@ public class BuyIngredientCommand extends Command { public static final String MESSAGE_USAGE = "\nTo buy ingredient:\n" + COMMAND_WORD + " ingredient/INGREDIENT1_NAME qty/INGREDIENT1_QTY" + "[, ingredient/INGREDIENT2_NAME, qty/INGREDIENT2_QTY...]\n" - + "Example:\n" + + "Example:" + COMMAND_WORD + " ingredient/rice qty/200g, ingredient/chicken qty/100g"; protected Ui ui; diff --git a/src/main/java/seedu/cafectrl/command/EditPriceCommand.java b/src/main/java/seedu/cafectrl/command/EditPriceCommand.java index c5c4eb059b..a021f7f9bc 100644 --- a/src/main/java/seedu/cafectrl/command/EditPriceCommand.java +++ b/src/main/java/seedu/cafectrl/command/EditPriceCommand.java @@ -10,7 +10,7 @@ */ public class EditPriceCommand extends Command { public static final String COMMAND_WORD = "edit_price"; - public static final String MESSAGE_USAGE = COMMAND_WORD + "To edit price of a menu item: \n" + public static final String MESSAGE_USAGE = "To edit price of a menu item: \n" + "edit_price index/DISH_INDEX price/NEW_PRICE\n" + "Example: edit_price index/1 price/4.50"; diff --git a/src/main/java/seedu/cafectrl/command/ViewTotalStockCommand.java b/src/main/java/seedu/cafectrl/command/ViewTotalStockCommand.java index b0f1dedae5..6cd6d1ec88 100644 --- a/src/main/java/seedu/cafectrl/command/ViewTotalStockCommand.java +++ b/src/main/java/seedu/cafectrl/command/ViewTotalStockCommand.java @@ -10,7 +10,7 @@ public class ViewTotalStockCommand extends Command { public static final String COMMAND_WORD = "view_stock"; - public static final String MESSAGE_USAGE = "To view pantry stock:\n " + COMMAND_WORD; + public static final String MESSAGE_USAGE = "To view pantry stock:\n" + COMMAND_WORD; protected Ui ui; protected Pantry pantry; private ArrayList pantryStock; diff --git a/src/main/java/seedu/cafectrl/storage/Decoder.java b/src/main/java/seedu/cafectrl/storage/Decoder.java index 79956b6a13..b26c805bf1 100644 --- a/src/main/java/seedu/cafectrl/storage/Decoder.java +++ b/src/main/java/seedu/cafectrl/storage/Decoder.java @@ -80,7 +80,7 @@ public static Pantry decodePantryStockData(ArrayList encodedPantryStock) ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); } else { Ingredient ingredient = new Ingredient(decodedData[0], - Integer.parseInt(decodedData[1]), decodedData[2]); + Integer.parseInt(decodedData[1].trim()), decodedData[2]); pantryStock.add(ingredient); } } @@ -99,7 +99,7 @@ private static boolean isValidPantryStockFormat(String[] decodedPantryStock) { return false; } else { try { - Integer.parseInt(decodedPantryStock[1]); + Integer.parseInt(decodedPantryStock[1].trim()); } catch (NumberFormatException e) { ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); return false; diff --git a/src/main/java/seedu/cafectrl/storage/Encoder.java b/src/main/java/seedu/cafectrl/storage/Encoder.java index 5f1894856e..22da204134 100644 --- a/src/main/java/seedu/cafectrl/storage/Encoder.java +++ b/src/main/java/seedu/cafectrl/storage/Encoder.java @@ -66,9 +66,14 @@ public static ArrayList encodePantryStock(Pantry pantry) { ArrayList pantryStockInString = new ArrayList<>(); ArrayList pantryStock = pantry.getPantryStock(); for (Ingredient ingredient : pantryStock) { - String encodedIngredient = ingredient.getName() + DIVIDER - + ingredient.getQty() + DIVIDER + ingredient.getUnit(); - pantryStockInString.add(encodedIngredient); + StringBuilder encodedIngredient = new StringBuilder(); + encodedIngredient.append(ingredient.getName()); + encodedIngredient.append(DIVIDER); + encodedIngredient.append(ingredient.getQty()); + encodedIngredient.append(DIVIDER); + encodedIngredient.append(ingredient.getUnit()); + encodedIngredient.append(System.lineSeparator()); + pantryStockInString.add(encodedIngredient.toString()); } return pantryStockInString; }