public class GroceryMatch
extends java.lang.Object
Constructor and Description |
---|
GroceryMatch()
DO NOT EDIT CONSTRUCTOR
|
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
calcMaxNumServing(Recipe recipe)
Calculate what is the maximum number of servings of this recipe using current GroceryList.
|
void |
handleShow()
DO NOT EDIT THIS METHOD
Handle the command when you try to show how many servings are possible.
|
void |
handleUse(java.util.Scanner stdin)
Handle the command when you try to use a recipe.
|
java.lang.Boolean |
initialize(java.lang.String groceryFile,
java.lang.String recipeFile)
DO NOT EDIT THIS METHOD
This method will initialize groceries and recipes.
|
static void |
main(java.lang.String[] args)
DO NOT EDIT THIS METHOD
The main method initializes the GroceryMatch object
and call the initialize method before starting the main menu loop.
|
void |
mainLoop(java.util.Scanner stdin)
DO NOT EDIT THIS METHOD
Main loop of GroceryMatch.
|
static void |
print(GroceryList groceries)
Print all the ingredient names and quantities in a GroceryList.
|
static void |
print(RecipeList recipes)
Print all the recipes in a RecipeList.
|
void |
reportShortage(Recipe recipe,
java.lang.Integer numOfServing)
This method is call when the desired number of servings is greater than
maximum possible number of servings.
|
void |
updateGroceries(Recipe recipe,
java.lang.Integer numOfServing)
Reduce the quantities in GroceryList since you have used them for serving.
|
public java.lang.Integer calcMaxNumServing(Recipe recipe)
recipe
- The recipe that you want to serve.public void reportShortage(Recipe recipe, java.lang.Integer numOfServing)
recipe
- The recipe that you can not serve.numOfServing
- The number of servings of the recipe.public void updateGroceries(Recipe recipe, java.lang.Integer numOfServing)
recipe
- The recipe you are serving.numOfServing
- The number of servings of the recipe.public void handleUse(java.util.Scanner stdin)
stdin
- The scanner for input.public static void print(GroceryList groceries)
groceries
- The GroceryList you want to print.public static void print(RecipeList recipes)
recipes
- The RecipeList you want to print.public void handleShow()
public void mainLoop(java.util.Scanner stdin)
stdin
- The Scanner for input.public java.lang.Boolean initialize(java.lang.String groceryFile, java.lang.String recipeFile)
groceryFile
- filename of groceriesrecipeFile
- filename of recipespublic static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException