I have a problem in a GUI i am trying to build. Below is the question and I was hoping you could help me out with what to do. Basically, I have do the first program which is to create a GUI but I am having a problem with what to do in the second program, In terms of the menu. Please help me out here. Thanx a lot...
The task is to write two programs. The first will provide a GUI which lets
the user enter and save recipes, where a recipe has the form
INGREDIENT1 : QUANTITY1
INGREDIENTn : QUANTITYn
where the quantities are right for one person, e.g.
egg : 1
butter : 0.25 oz
spaghetti : 2oz
bacon : 1oz
egg : 1
The GUI should allow the user to add an arbitrary number of ingredients,
and it should be possible to use any measure the user likes when specifying
quantities (so it should be possible to say that a recipe requires 1 oz of butter
or that it requires 28 grams of butter), though the user should stick to the
same units for the same ingredients (so they should not have one recipe that
requires 0.5 pints of milk and another that requires 0.6 litres of milk).
The second program will read a collection of saved recipes and then let the
user specify a set of menus, and will produce an appropriate shopping list
for the given set of menus, e.g.
Omelette: 2 people
Spaghetti carbonara: 4 people
should produce the list
egg : 6
bacon : 4oz
It is very likely that you will want to represent recipes as serializable objects
and save/restore them using ObjectOutputStreams and ObjectInputStreams.
Other approaches to the problem will not be marked down, but this seems
like a good way to proceed.