Starting from:

$24

Recipe Wrangler

Recipe.javaRecipeList.javaRecipeTester.java





RecipeWrangler.java
For this program you will maintain a database system for storing and retrieving recipes. Each recipe has a name, a list of ingredients, and instructions. The program adds recipes from a file at the start and then allows the user to add and edit recipes. The program user is able to list the available recipe names and display the information about a specific recipe. When the program starts, the user is asked for recipe file and the program loads all recipes found in the file. When the program ends, the user is asked for a filename to write (save) all recipes. The save overwrites the file if it already exists.We provide a sample recipes.txt file to get you started, but you can create your own recipe file using a text editor (Eclipse can edit text files) or using your program once you implement the Add recipe and Exit (and save to file) options. The required file format is describe later.Welcome messageRecipeWrangler is the main class and it contains the main method that gets the program going. It displays the program welcome message and starts the main menu loop as described below.Recipe Wrangler 2015
Let us help you keep track of your favorite recipes.The Main Menu loopThe main menu includes options for maintaining the database (list) of recipes. There is no "remove recipe" option. Each option is outlined here. Your program must implement each option according to its specification.Main Menu
---------
1. Display recipe names (sorted)
2. Display/Edit/Add a recipe
3. Load recipes from a file
4. Save recipes to a file
5. Exit
Enter choice:
1. Display recipe names (sorted)Display a list of the names of the recipes. If no recipes have been loaded from a file or entered by the user, disp the message: No recipesMain Menu
---------
1. Display recipe names (sorted)
2. Display/Edit/Add a recipe
3. Load recipes from a file
4. Save recipes to a file
5. Exit
Enter choice: 1
No recipes
Display a list of the names of the recipes. Keep the recipes in order sorted by name.Main Menu
---------
1. Display recipe names (sorted)
2. Display/Edit/Add a recipe
3. Load recipes from a file
4. Save recipes to a file
5. Exit
Enter choice: 1
CEREAL
CHOCOLATE CHIP COOKIES
PANCAKES
PESTO
2. Display/Edit/Add a recipeDisplay recipe and allow user to replace ingredients or instructions if the recipe name exists in the recipe list. If a recipe with that name is not found in the recipe list, prompt the user for ingredients and instruction, create the recipe instance and add it to the list of recipes.Pseudocode for how to handle Display/Edit/New process array or liet
Prompt the user for a recipe name.
Convert the name to all CAPS.
Get a recipe with that name from the database (if there is one).
If there is no recipe with that name
Ask user for the recipe's ingredients
(newline means the end of the ingredients)
Ask the user for the recipe's instructions
(newline means the end of the instructions)
Create an instance of the Recipe (name,ingredients,instructions)
Add the new recipe to the list of recipes
Sort the recipe list
(Make Recipe class implement java.lang.Comparable<Recipe and then user either Arrays.sort() or the sort() method of ArrayList class.)
If there is a recipe with that name
Display the recipe's name, ingredients, and instructions.
Display the edit recipe menu
Get the user's edit menu choice
If user selects 1
Get a new list of ingredients
Replace the ingredients of the recipe with the new list
If user selects 2
Get the new instructions
Replace the instructions of the recipe with the new ones
If user selects 3 (or any other input)
Exit the edit recipe menu
Note: Do convert the name to all upper case letters before saving it as part of recipe. Otherwise, leave each field just it is entered by the user.3. Load recipes from a fileUse a Scanner to read data from a file that contains recipe information. The file format is as follows:Line 1: the number of recipes in the file (will be an integer value)
Line 2: name of first recipe
Line 3: ingredients for first recipe
Line 4: insructions for first recipe
Line 5: name of second recipe
Line 6: ingredients for second recipe
Line 7: insructions for second recipe
... (3 lines per recipe)Example recipes file contents:4
Chocolate chip cookies
flour, sugar, oil, butter, vanilla, chocolate chips
mix all ingredients, make cookies, bake 10 min at 350 degrees
Pesto
1 C basil, 1/2 C parmesan cheese, 1/3 C olive oil, 1/4 C walnuts, 1 clove garlic, salt and pepper to taste
mix all ingredients except cheese in a food processor, chop for 1 minute, add cheese and enjoy
PANCAKES
flour, eggs, milk, baking powder, salt, cooking oil
mix all ingredients (except oil), add oil to skillet, pour batter for each pancake, cook one side then flip when bubbles appear
CREPE
2 eggs, 1C flour, 1/2 C milk, 1/2 C water, 1/2 t salt, 2 T butter
whisk flour, salt, and eggs; add milk and water; pour 1/4 C in small oiled skillet and coat bottom with batter, cook until light brown (~2 minutes) and flip.
Create a Scanner connected to the data file
Read the first line of the file and parse as an int value (number of recipes).
For each recipe in the file:
Get the next line and save it as "name" (save as upper case)
Search program's recipe list for a recipe with this name
If a recipe with same name is found, get it:
Scan next line and save it as ingredients
Replace the ingredients for this Recipe with ingredients
Scan next line and save it as insructions
Replace the instructions for the found Recipe with instructions
Close scanner connected to the input file
4. Save recipes to a file
Writes all recipes in the program to a file in aphabetical order (by name).
Create a PrintWriter connected to the output file name
Write the number (as an int value) of recipes as the first line of the file.
For each recipe in the file:
Write the name of the recipe (write name as upper case and on its own line)
Write the ingredient list for the recipe and a newline character
Write the instruction list for the recipe
Close the printwriter connected to the input file
5. ExitDisplay the exit message: Thanks for using RecipeWrangler!5. Exit
Thanks for using RecipeWrangler!

More products