Question: You need to create a Java application that stores information about recipes and their nutritional information. Each recipe has a list of ingredients that must

You need to create a Java application that stores information about recipes and their nutritional information. Eachrecipehas a list ofingredientsthat must be stored by the program, and each ingredient has anameand anumber of kilojoulesassociated with it.
What would be the best class design for the program?
Question 1Answer
a.
The program should have anIngredientclass only, which should have fields foringredientName,kilojoule, andrecipeName.
b.
The program should have aRecipeclass only, which shouldhold a list ofingredient namesand ofingredientkilojoules.
c.
The program should have aRecipeclass and anIngredientclass. TheRecipeclass should hold a list ofIngredientobjects, and theIngredientclass should havenameandkilojoulesas fields.
d.
The program should have aRecipeclass and anIngredientclass. TheIngredientclass should have aRecipeobject, aname,andkilojoulesas fields.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!