Project Overview

Mr. and Mrs. Party-Animal like to invite people regularly to their house for dinner. They hope to enter and win the next Reality Cooking TV show. From past experience they have found that they need to plan the meal well in advance of the gathering to ensure the dinner is successful. To cut down the time spent on meal planning as well as to ensure everything gets purchased and cooked properly, you are volunteered to write a Java program to capture the whole meal-planning process. The goal of the program is to exercise basic Java programming techniques using arrays, classes and objects. The assignment is composed of two parts. In Part1, you are to create a DOS command line application and in Part2 you create an appropriate GUI for the same application.

Problem Description

Part1: Command Line Based Application

For party meal planning, a database of recipes is needed. This recipe database, or more precisely, the file management system should be able to add a new recipe, delete an existing recipe, find a particular recipe based on its name and print out all the recipes currently in the database. For each recipe, it will have a unique recipe name, the number of people the recipe serves, a list of all the ingredients required (more will be explained about this a little later), a description of the procedures involved for cooking the dish. Each ingredient has its own name, a quantity that specifies the amount of ingredient needed and a measure unit used for the quantity (either kg or g). The recipe should handle inserting a new ingredient, deleting an existing ingredient, and changing both the quantity and measure unit of an ingredient.

To actually practice meal-planning you need a database of meals that you will have in the near future. For each meal, you also have to know the name of the meal that you are planning, together with the date on which the meal will take place, the number of people who will be present for the meal and a list of recipes planned for that particular meal. You can insert a new meal to the database, delete an existing meal from the database, find a meal based on its name, and convert the quantities of ingredients per recipe based on the number of people in the meal. (The number of people specified in a recipe might not be the same as the number of people attending the meal). You should do an amount conversion for each ingredient in the recipe, make a shopping list for a particular meal (collect all ingredients needed and add them up) and print it out.

An array of up to 30 references to objects is required for the ingredient list, the recipe database and the meal database. Items in the array should be kept in an ascending order (wherever practicable) according to the alphabetical order of the name field. Your program should be able to read from standard input and process it according to the commands specified. The commands will be in the following format (between each group of commands, there will be exactly one blank line as the separator):

(a) RECIPE command

Note that END signifies the end of the current variable-length input item. For
instance, END is used to inform of the end of ingredient specification.
RECIPE recipe-name
number of people this recipe feeds
ingredient-name ingredient quantity measure unit
ingredient-name ingredient quantity measure unit
.
.
.
END
description of procedures for cooking the dish
END

(b) MEAL command

MEAL meal-name
number of people attending the meal
date of this meal
recipe name
recipe name
.
.
.
END

(c) INGRED command

This command adds a new ingredient to an existing recipe or modifies an existing ingredient. If the ingredient does not already exist for the specified recipe name, then it is added to that recipe. Otherwise, the corresponding attributes are modified according to whatever specified in the input.

INGRED recipe-name ingredient-name ingredient quantity measure unit

This command deletes an ingredient of an existing recipe. Any reference to this ingredient should be removed from the recipe.

INGRED recipe-name ingredient-name 0 g

(d) FIND RECIPE recipe-name

FIND MEAL meal-name

These two commands will find the specified recipe or meal, based on the name and print out all the corresponding data. (e.g., for recipe, print out the name, the number of people for which the recipe is intended, a list of all the ingredients needed, including the quantity and measure unit, and a description of procedures. Similar output follows for a meal.)

(e) DELETE RECIPE recipe-name

DELETE MEAL meal-name

These two commands will delete the specified recipe or meal from the recipe database or the meal database.

(f) PRINT RECIPES

PRINT MEALS
PRINT SHOPLIST meal-name

For the first two commands, the recipe database or the meal database will be traversed and all the recipes or meals will be printed out (including all the attributes that go along with them like names, ingredients and so on.) The last command should collect all ingredients, add them up, and print them out.

Sample Input and Output

Below is a sample input file your program might read from.

RECIPE Cake
6
flour 1000 g
milk 500 g
sugar 1.2 kg
END
Put it in a bowl
Mix
Heat
Eat
END

RECIPE Soup
8
stock 1200 g
onions 500 g
beef 100g
END
Chop the onions
Heat over low flame
Serve with bread
END

RECIPE Curry
10
lemongrass 300 g
chilli 30 g
END
Mix
Cook
Serve with rice
END

RECIPE Pasta
2
spaghetti 500 g
tomatoes 1.2 kg
END
Boil spaghetti
Make sauce
Put the sauce on the spaghetti
END

PRINT RECIPES
INGRED Cake
eggs 30 g
INGRED Curry
chilli 1200 g
INGRED Soup
beef 0 g
FIND RECIPE Curry
FIND RECIPE Cake
FIND RECIPE Soup
DELETE RECIPE Soup
PRINT RECIPES
$$$ // use this to mark EOF (end of input)
MEAL MonNight
12
121113
Soup
END
PRINT SHOPLIST MonNight
PRINT MEALS
FIND MEAL MonNight
DELETE MEAL MonNight

Here is an output file produced from the sample input. You should follow exactly the format of the output file here since we will use your output file as the basis for evaluating program.

Recipe Cake added to database.
Recipe Soup added to database.
Recipe Curry added to database.
Recipe Pasta added to database.
RECIPE Cake
# of people per serving: 6
flour 1.000 kg
milk 500 g
sugar 1.200 kg
Procedure:
Put it in a bowl
Mix
Heat
Eat
RECIPE Curry
# of people per serving: 10
chilli 30 g
lemongrass 300 g
Procedure:
Mix
Cook
Serve with rice
RECIPE Pasta
# of people per serving: 2
spaghetti 500 g
tomatoes 1.200 kg
Procedure:
Boil spaghetti
Make sauce
Put the sauce on the spaghetti
RECIPE Soup
# of people per serving: 8
onions 500 g
stock 1.200 kg
Procedure:
Chop the onions
Heat over low flame
Serve with bread
30g of eggs is added to Cake.
chilli in Curry is changed to 1.200kg
beef in Soup is deleted
RECIPE Curry
# of people per serving: 10
chilli 1.200 kg
lemongrass 300 g
Procedure:
Mix
Cook
Serve with rice
RECIPE Cake
# of people per serving: 6
eggs 30 g
flour 1.000 kg
milk 500 g
sugar 1.200 kg
Procedure:
Put it in a bowl
Mix
Heat
Eat
RECIPE Soup
# of people per serving: 8
onions 500 g
stock 1.200 kg
Procedure:
Chop the onions
Heat over low flame
Serve with bread
Recipe Soup deleted.
RECIPE Cake
# of people per serving: 6
eggs 30 g
flour 1.000 kg
milk 500 g
sugar 1.200 kg
Procedure:
Put it in a bowl
Mix
Heat
Eat
RECIPE Curry
# of people per serving: 10
chilli 1.200 kg
lemongrass 300 g
Procedure:
Mix
Cook
Serve with rice
RECIPE Pasta
# of people per serving: 2
spaghetti 500 g
tomatoes 1.200 kg
Procedure:
Boil spaghetti
Make sauce
Put the sauce on the spaghetti
Meal MonNight added to database
Shopping List for MonNight:
flour 2.000 kg
milk 1.000 kg
onions 750 g
stock 1.800 kg
sugar 2.400 kg
Meal name: MonNight
date: 121113
# of people attending: 12
RECIPE:
Soup
Cake
Meal name: MonNight
# of people attending: 12
date: 121113
RECIPE:
Soup
Cake
MEAL MonNight deleted

Part 2: The GUI application

Design a GUI application to manage your database of recipes. The GUI needs to be able to accomplish the same input and output tasks as the command line driven program was able to do.

The appearance of the GUI is entirely up to you to decide. Feel free to add any extra features that you feel are useful. You may also use components or layout managers that not mentioned in this document. Check online Java documents for details.

NOTE: It is not expected that you should need to rewrite any of the classes from Part 1 of the Assignment. Rather you will create instances of the relevant classes when you need them for Part 2. The GUI for this assignment should create at least two new classes: one being the JFrame for displaying the GUI panel, and the GUI JPanel with its components.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.