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 branch 'master' into 23-parser-for-list-ingredients-v1.0
- Loading branch information
Showing
3 changed files
with
33 additions
and
10 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 |
---|---|---|
@@ -1,19 +1,37 @@ | ||
package seedu.duke.command; | ||
|
||
import seedu.duke.data.Menu; | ||
import seedu.duke.data.dish.Dish; | ||
import seedu.duke.ui.Ui; | ||
|
||
/** | ||
* Deletes a menu item identified using it's last displayed index from the menu. | ||
*/ | ||
public class DeleteDishCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "delete"; | ||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Deletes the menu item identified by the index number used in the last menu listing.\n" | ||
+ "Parameters: INDEX\n" | ||
+ "Example: " + COMMAND_WORD + " 1"; | ||
|
||
/** | ||
* Constructor for DeleteDishCommand | ||
* | ||
* @param index index of menu item to be deleted | ||
*/ | ||
public DeleteDishCommand(int index) { | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public void execute(Menu menu, Ui ui) { | ||
|
||
}; | ||
Dish selectedDish = menu.getMenuItemsList().get(index - Ui.OFFSET_LIST_INDEX); | ||
if (selectedDish != null) { | ||
ui.showDeleteMessage(selectedDish); | ||
} else { | ||
ui.showToUser("Please select a valid dish index :)"); | ||
} | ||
menu.removeDish(index); | ||
} | ||
} |
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