Question: Create the start to a cookbook using Java Homework Create a class named RecipeFactory (using a Factory design pattern) public static Recipe makeRecipe(String recipeType, String
Create the start to a cookbook using Java
Homework
- Create a class named RecipeFactory (using a "Factory" design pattern)
- public static Recipe makeRecipe(String recipeType, String recipeName, HashMap ingredients)
- public static final String (DESSERT and DINNER) Hint * use String Constant, NOT string literal*
- Dessert and Dinner
- Create an abstract class named Recipe
- protected HashMap ingredients
- Key: ingredient name
- Value: ingredient amount
- protected String name
- HashMap getIngredients()
- Can implement here
- String getName()
- Can implement here
- protected HashMap ingredients
- Extend your abstract class in DessertRecipe and DinnerRecipe
- Override toString
- Expected output below in Sample Cake Output
- Use the StringBuilder class
- Implement a constructor that takes String name and HashMap ingredients.
- Warning: assigning HashMap from constructor and memory
- new HashMap(hashMap)
- Override toString
- Sample Cake Output
- Hint: use to add a newline and \t to add the tab
- Since this will go through an autograder, you must exactly match the formatting (do not add an extra to the very end)

- Hint: use to add a newline and \t to add the tab
- Create a singleton class named Cookbook
- private Cookbook() { }
- private ArrayList recipes
- void addRecipe(Recipe r)
- void clearRecipes()
- ArrayList getRecipes()
- Cookbook getInstance()
Name: Cake Food Type: Dessert 3/4 cups milk 2/3 cups sugar 3/4 cups flour 1 tsp vanilla Name: Cake Food Type: Dessert 3/4 cups milk 2/3 cups sugar 3/4 cups flour 1 tsp vanilla
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
