Skip to content

Commit

Permalink
Merge pull request #60 from Joellimjr/v2.0
Browse files Browse the repository at this point in the history
edit checkstyle
  • Loading branch information
Joellimjr committed Mar 27, 2024
2 parents c2b17b1 + 80b9ef2 commit ad22b17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/java/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ public class Messages {
public static final String DIVIDER = "----------------";
public static final String INVALID_COMMAND = "Invalid command detected. Type 'help' for list of valid commands";
public static final String HELP = "Commands: ....";
public static final String INVALID_ADD_FORMAT ="Invalid command format. Please use format: " +
"'add [ITEM_NAME] qty/[QUANTITY_OF_ITEM] /[UNIT_OF_MEASUREMENT] cat/[CATEGORY] buy/[BUY_PRICE] sell/[SELL_PRICE]'";
public static final String INVALID_ADD_FORMAT ="Invalid command format. Please use format: " + "\n" +
"'add [ITEM_NAME] qty/[QUANTITY_OF_ITEM] /[UNIT_OF_MEASUREMENT] cat/[CATEGORY] " +
"buy/[BUY_PRICE] sell/[SELL_PRICE]'";
public static final String INVALID_DELETE_FORMAT ="Invalid command format. Please use format: 'del [ITEM_NAME]'";
public static final String INVALID_EDIT_FORMAT ="Invalid command format. Please use format: " +
"'edit [ITEM_NAME] qty/[NEW_QUANTITY]'";
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ public static void readFromFile(File fileName) {
public static void addToFile(ArrayList<Item> items, boolean ifAppend) {
assert items != null : "Items cannot be null.";
Item lastItem = items.get(items.size() - 1);
String descriptionAdded = (items.size() - 1) + " | " + lastItem.getItemName() +
" | " + lastItem.getQuantity() + " | " + lastItem.getBuyPrice() + " | " + lastItem.getSellPrice() +"\n";
String descriptionAdded = (items.size() - 1) + " | " + lastItem.getItemName() + " | " + lastItem.getQuantity()
+ " | " + lastItem.getBuyPrice() + " | " + lastItem.getSellPrice() + "\n";
updateFile(descriptionAdded, ifAppend);
}

public static void overwriteFile(ArrayList<Item> items, boolean ifAppend) {
assert items != null : "Items cannot be null.";
int length = items.size();
for (int index = 0; index < length; index++) {
String descriptionAdded = index + " | " + items.get(index).getItemName() + " | " + items.get(index).getQuantity()
+ " | " + items.get(index).getBuyPrice() + " | " + items.get(index).getSellPrice() + "\n";
String descriptionAdded = index + " | " + items.get(index).getItemName() + " | " +
items.get(index).getQuantity() + " | " + items.get(index).getBuyPrice() + " | " +
items.get(index).getSellPrice() + "\n";
if (index == 0) {
updateFile(descriptionAdded, ifAppend);
} else {
Expand Down

0 comments on commit ad22b17

Please sign in to comment.