forked from nusCS2113-AY1920S1/duke
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nusCS2113-AY1920S1#14 from 9hafidz6/master
added recipeCommand package
- Loading branch information
Showing
24 changed files
with
398 additions
and
120 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package duke.recipeCommand; | ||
|
||
import duke.exception.DukeException; | ||
import duke.recipebook.Dishes; | ||
import duke.recipebook.DishList; | ||
import duke.storage.Storage; | ||
import duke.task.TaskList; | ||
import duke.ui.Ui; | ||
|
||
public class AddDishCommand extends RecipeCommand { | ||
|
||
private Dishes dish; | ||
private int amount; | ||
private int Nb; | ||
|
||
public AddDishCommand(Dishes dish, int amount) { | ||
this.dish = dish; | ||
this.amount = amount; | ||
} | ||
|
||
@Override | ||
public void execute(DishList dish1, TaskList taskList, Ui ui, Storage storage) throws DukeException { | ||
|
||
try { | ||
dish1.addDish(dish); // add dish into list found in dishes class | ||
|
||
for( int i = 1; i < DishList.getSize(); i++) { | ||
if(DishList.getDish(i).getDishname().equals(dish.toString())){ | ||
Nb = i; | ||
break; | ||
} | ||
} | ||
dish1.getDish(Nb).setNumberOfOrders(amount); | ||
ui.showAddedDishes(dish.toString(), DishList.getDish(Nb).getTotalNumberOfOrders()); | ||
} catch (Exception e) { | ||
throw new DukeException("unable to add dish"); | ||
} | ||
} | ||
} |
Oops, something went wrong.