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 pull request #54 from NaychiMin/23-parser-for-list-ingredients-…
…v1.0 Task 23, Implement parsing support for listing ingredients .
- Loading branch information
Showing
3 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
17 changes: 14 additions & 3 deletions
17
src/main/java/seedu/duke/command/ListIngredientCommand.java
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,30 @@ | ||
package seedu.duke.command; | ||
|
||
import seedu.duke.data.Menu; | ||
import seedu.duke.data.dish.Dish; | ||
import seedu.duke.ui.Ui; | ||
|
||
/** | ||
* Lists all ingredients used in the selected dish to the user. | ||
*/ | ||
public class ListIngredientCommand extends Command{ | ||
public class ListIngredientCommand extends Command { | ||
public static final String COMMAND_WORD = "list_ingredients"; | ||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Lists out the ingredients needed along with the quantity for a specific dish.\n" | ||
+ "Parameters: INDEX\n" | ||
+ "Example: " + COMMAND_WORD + " 1"; | ||
|
||
public ListIngredientCommand(int listIndex) { | ||
this.index = listIndex; | ||
} | ||
|
||
@Override | ||
public void execute(Menu menu, Ui ui) { | ||
ui.printIngredients(menu, index); | ||
}; | ||
Dish selectedDish = menu.getMenuItemsList().get(index - Ui.OFFSET_LIST_INDEX); | ||
if (selectedDish != null) { | ||
ui.printIngredients(selectedDish); | ||
} else { | ||
ui.showToUser("Please select a valid dish 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