OO Programming in Java

Class 9

Quiz


Food Counter

Design an Object Model for a food value log which uses the computer to tack dietary intake. Food types and quantities are entered. The amount of fat carbohydrates and protein are computed using a database from the entered type and amount. A log can be displayed showing the constituent values by data.

Object Model Solution


Note

Each FoodLogEntry has a reference to the appropriate Food object in the FoodDatabase.

The goodness ..

A change to the food database will be reflected in every FoodLogEntry associated with that Food.

The badness ..

The log is not immutable.