diff --git a/src/main/java/seedu/cafectrl/command/EditPriceCommand.java b/src/main/java/seedu/cafectrl/command/EditPriceCommand.java index c014e7cfa3..5e31226c49 100644 --- a/src/main/java/seedu/cafectrl/command/EditPriceCommand.java +++ b/src/main/java/seedu/cafectrl/command/EditPriceCommand.java @@ -22,11 +22,11 @@ public class EditPriceCommand extends Command { protected Menu menu; protected Ui ui; private final int menuID; - private final float newPrice; + private final float newDishPrice; - public EditPriceCommand(int menuID, float newPrice, Menu menu, Ui ui) { + public EditPriceCommand(int menuID, float newDishPrice, Menu menu, Ui ui) { this.menuID = menuID; - this.newPrice = newPrice; + this.newDishPrice = newDishPrice; this.menu = menu; this.ui = ui; } @@ -37,13 +37,13 @@ public EditPriceCommand(int menuID, float newPrice, Menu menu, Ui ui) { */ public void execute() { logger.info("Executing EditPriceCommand..."); - Dish dish = menu.getDishFromId(this.menuID - Ui.OFFSET_LIST_INDEX); + Dish dish = menu.getDishFromId(menuID - Ui.OFFSET_LIST_INDEX); // Checks for original price - if (dish.comparePrice(this.newPrice) == 0) { - this.ui.showToUser(ErrorMessages.EDIT_SAME_PRICE); + if (dish.comparePrice(newDishPrice) == 0) { + ui.showToUser(ErrorMessages.EDIT_SAME_PRICE); } else { - dish.setPrice(this.newPrice); + dish.setPrice(newDishPrice); ui.showEditPriceMessage(dish.toString()); } } diff --git a/src/main/java/seedu/cafectrl/storage/Storage.java b/src/main/java/seedu/cafectrl/storage/Storage.java index 4e9f8fee00..0fe283fc98 100644 --- a/src/main/java/seedu/cafectrl/storage/Storage.java +++ b/src/main/java/seedu/cafectrl/storage/Storage.java @@ -154,7 +154,7 @@ private void saveMenu(Menu menu) throws IOException { */ public Pantry loadPantryStock() { try { - ArrayList encodedPantryStock = this.fileManager.readTextFile(FilePath.PANTRY_STOCK_FILE_PATH); + ArrayList encodedPantryStock = fileManager.readTextFile(FilePath.PANTRY_STOCK_FILE_PATH); if (!isFileEmpty(encodedPantryStock) && isFileCorrupted(encodedPantryStock) && isHashingEnabled) { isPantryStockTampered = true; logger.log(Level.INFO, "Tampered Pantry Stock file"); @@ -177,7 +177,7 @@ public Pantry loadPantryStock() { * @throws IOException if the file is not found in the specified file path */ private void savePantryStock(Pantry pantry) throws IOException { - this.fileManager.overwriteFile(FilePath.PANTRY_STOCK_FILE_PATH, Encoder.encodePantryStock(pantry)); + fileManager.overwriteFile(FilePath.PANTRY_STOCK_FILE_PATH, Encoder.encodePantryStock(pantry)); } //@@author NaychiMin @@ -214,7 +214,7 @@ public Sales loadOrderList(Menu menu) { */ private void saveOrderList(Sales sales) throws IOException { logger.info("Saving orders..."); - this.fileManager.overwriteFile(FilePath.ORDERS_FILE_PATH, Encoder.encodeSales(sales)); + fileManager.overwriteFile(FilePath.ORDERS_FILE_PATH, Encoder.encodeSales(sales)); } //@@author ziyi105