Professional Documents
Culture Documents
0 Functional Specification
This document describes version 1.0 of the Nutricalc™ application. Nutricalc is an
application that keeps a database of nutritional data for various foods, and (optionally)
calculates nutritional statistics for proposed meals.
1. Components
Nutricalc 1.0 consists of these components:
a simple in-memory database of nutritional statistics for various foods
a simple command-line user interface allowing the user to:
o add new foods to the database
o delete foods from the database
o list the foods in the database
o quit the application
an optional meal calculator that allows the user to create “meals” and obtain
nutritional statistics for those them. A “meal” is a set of foods chosen from the
food database.
Note that “name” is a pointer to enough bytes to store the name as a C string.
We’re using float for the numerical data because we have no need for the increased
precision we get with double, so there’s no need to use up the extra memory.
“Category” is the name of a C++ enumerated type that should be defined as follows:
enum Category {
unknown = -1, meat, poultry, seafood, dairy, vegetable,
fruit, grain, sweet, nCategories
};
Foods are stored in the database in a linear, indexed sequence. The first item in the
database has index 0 (zero), the second has index 1 (one), etc. A database with n foods
in it will use index numbers in the range [0 .. (n-1)].
3. Memory Management
It is your responsibility to manage your dynamically-allocated memory (i.e. the memory
you create with the new command). Your application must release all of the memory it
allocates before it quits. Failure to do so is a memory leak, which is a very serious bug
(and which will cause serious consequences for your grade).
*
But also use your common sense – I expect to see your own name after “Implemented by:”, not my name.