Part 1: Imaging the following situation: You have a set of recipes of various dishes that you cook for yourself. For each recipe you have a list of ingredients. You want to write a program that will randomly select 7 recipes ( for each day of the week) and will output a grocery list of ingredients that you need to buy in order to cook the selected dishes. Here's how you are going to implement this task.
You are provided with a file [url removed, login to view] which I will provide. This file represents a kind of database for the recipe names and corresponding ingredients. On each line it contains a formatted representation of recipe ingredients: i.e., each line has the name of a recipe followed by a vertical line, followed by a list of ingredients ( with corresponding quantities in front). The quantity is separated from the corresponding name of the ingredient with a dash, and ingredients are separated by semicolons from each other. For example:
Macaroni Cheese | 1 - macaroni; [url removed, login to view] - butter; 0.2 - flour; 1 - cheddar cheese; 0.5 - milk; 0 - salt;
Avocado Salad | 2 - avocado; 1 - onion; 1 - rice; 0 - salt;
There is one and only one recipe per line. Here, for simplicity, we do not have the units of measurement for the quantity of an ingredient, assuming that they are already prefixed for each ingredient (e.g. macaroni is measured in pounds, milk and cheese in cups etc.). Zero in front of an ingredient means - "to taste".
(Comment: When reading the names of the recipes and ingredients discard all extra blanks so, for example, the name of the ingredient should be a string "cheddar cheese" whether it is written 1-cheddar cheese; or 1 - cheddar cheese ; in the file. Also, ignore cases.)
The program should read [url removed, login to view], randomly choose 7 different recipes from [url removed, login to view] and output a list of groceries for a week (all ingredients from the chosen recipes should be added up).
******See other files for a text file containing the entire project description, the continued project description is also available in the deliverables section******
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
(Continued from description)
Create a class Recipe and a class IngredientNode. Each object of type Recipe should have a name (name of the recipe) and a list of ingredients. Specifically, this list of ingredients*should be implemented as a linked list*of IngedientNodes, where each IngredientNode should have fields String name, double quantity, and a link to a next node.
Your driver program should be called [url removed, login to view] and should have (among others) the following methods:
* public static Recipe getRecipe(int line)- should return an object Recipe from the specified line of file [url removed, login to view] (with a linked list of ingredients). Let the line numbering start from 1 (not 0).
* public static void printIngredients(Recipe r)- print out all the ingredients (names and quantities) of the given Recipe object .
* public static Recipe findRecipe(String recipeName)- find the recipe with a given name in the [url removed, login to view] file and return a corresponding Recipe object. Should throw a RecipeNotFoundException if the recipe with that name is not in the file.
* public static void printAllRecipeNames() - should read and print out the names of all recipes from the [url removed, login to view]
* public static void chooseRandomRecipes(int n) - randomly choose n recipes from the [url removed, login to view] file and print out their names;
* public static void printGroceryList() - randomly choose 7 recipes from the [url removed, login to view] file and print out the resulting list of ingredients and their quantities (the quantities should be added up for identical ingredients). (Note: You have to use linked list representations of the recipes here! Your resulting grocery list should itself be a linked list of ingredients.)
Create a GUI (graphical user interface) for this program. Call your file Project6GUI.java. It should have:
- Two buttons labeled "Get Recipes" and "Show Grocery List";
- Two text areas labeled "Recipes for a week" (editable) and "Groceries for a week" (not editable).
It should have exactlythe following functionality:
- When the button "Get Recipes" is pushed the program should read from the [url removed, login to view] file, randomly select 7 recipes, and display them in the "Recipes for the week" area, one recipe per line.
- When the button "Show Grocery List" is pushed the program should read the recipe names from the "Recipes for the week" area , go to the [url removed, login to view] file, find these recipes and display a resulting grocery list in the "Groceries for a week" area.
Note that when the button "Show Grocery List" is pushed you do not randomly choose recipes again but read them from the "Recipes for the week" text area instead. (Since "Recipes for the week" is an editable text area you should be able to type the (valid) names of the recipes yourself and pushing the "Show Grocery List" button should produce the corresponding grocery list nevertheless)