UMBC CMSC 202
Project 1
Welcome to Goodburger!
Posted: Monday 2/4/02
Design Document Due Date: design1.txt is due
before midnight, Sunday 2/10/02
Project Due Date: Before midnight, Sunday 2/17/02
Objectives
- To become familiar with C++ syntax
- To understand the recursive process and how to write recursive functions
- To become familiar with a basic make file
Project Description
As the title says, "Welcome to Goodburger!" Goodburger is the newest fast food
restaurant in the University Commons. It offers a variety of drinks, entrees,
side orders, and desserts at student (and faculty) affordable prices. To keep
its prices low, Goodburger would like to automate its serving system in accordance
with the Sample Run below. The specification is not too fancy yet, but if you
do a good job, they just might hire you to do the one million dollar upgrade.
Well, this job doesn't seem too tough. After all, you have worked with files,
basic sorting, and menus before. But Kel, the owner of Goodburger, is a little
different. He insists that the program contain no for
,
while
, or do-while
statements! It's a good thing that
you are now an expert in recursion.
Further Specification
As stated, your program may contain NO loops in order to receive 100% credit.
That means no for loops, while loops, do loops, goto statements, or any
other syntax that can implement looping. You may use only recursive function
calls to implement looping.
In addition,
- The Goodburger menu must be displayed in sorted order using the
food item as the sort key. You MUST use a selection sort.
- It is probably wisest to follow the format of the output in the Sample Run, but you
do not have to. If you do not, be sure that your output contains the same information
as the Sample Run and is neatly and appropriately formatted (e.g., all
strings left-justified, prices to two decimal places and aligned at the decimal point).
- You must use C++, not C, stream and file I/O.
Assumptions
You may assume the following:
- The customer will respond to any queries with the appropriate type of data.
That is, integers for integers, characters for characters, etc. However,
the data may be out of range (see Error Handling below).
- The customer will order at most 10 items from the menu. If he/she orders the same
item more than once, it will appear more than once on his/her bill.
A Sample Run
linux2[1]% Proj1 food1.dat
Input file is empty.
linux2[2]% Proj1 food2.dat
Welcome to Goodburger, home of the Goodburger.
May I take your order?
Here's our menu:
1) brownie $ 1.75
2) cheeseburger $ 2.75
3) cola $ 1.25
4) cole slaw $ 0.99
5) diet cola $ 1.25
6) french fries $ 1.25
7) ginger ale $ 1.25
8) hamburger $ 2.50
9) hot dog $ 1.50
10) ice cream cone $ 1.90
11) ice cream sundae $ 2.10
12) milk $ 1.35
13) onion rings $ 1.45
14) orange soda $ 1.25
15) pie $ 1.65
16) potato chips $ 1.50
17) salad $ 2.25
18) water $ 0.75
Which item would you like?
2
Would you like another item? (y or Y)
y
Here's our menu:
1) brownie $ 1.75
2) cheeseburger $ 2.75
3) cola $ 1.25
4) cole slaw $ 0.99
5) diet cola $ 1.25
6) french fries $ 1.25
7) ginger ale $ 1.25
8) hamburger $ 2.50
9) hot dog $ 1.50
10) ice cream cone $ 1.90
11) ice cream sundae $ 2.10
12) milk $ 1.35
13) onion rings $ 1.45
14) orange soda $ 1.25
15) pie $ 1.65
16) potato chips $ 1.50
17) salad $ 2.25
18) water $ 0.75
Which item would you like?
14
Would you like another item? (y or Y)
y
Here's our menu:
1) brownie $ 1.75
2) cheeseburger $ 2.75
3) cola $ 1.25
4) cole slaw $ 0.99
5) diet cola $ 1.25
6) french fries $ 1.25
7) ginger ale $ 1.25
8) hamburger $ 2.50
9) hot dog $ 1.50
10) ice cream cone $ 1.90
11) ice cream sundae $ 2.10
12) milk $ 1.35
13) onion rings $ 1.45
14) orange soda $ 1.25
15) pie $ 1.65
16) potato chips $ 1.50
17) salad $ 2.25
18) water $ 0.75
Which item would you like?
6
Would you like another item? (y or Y)
y
Here's our menu:
1) brownie $ 1.75
2) cheeseburger $ 2.75
3) cola $ 1.25
4) cole slaw $ 0.99
5) diet cola $ 1.25
6) french fries $ 1.25
7) ginger ale $ 1.25
8) hamburger $ 2.50
5) diet cola $ 1.25
6) french fries $ 1.25
7) ginger ale $ 1.25
8) hamburger $ 2.50
9) hot dog $ 1.50
10) ice cream cone $ 1.90
11) ice cream sundae $ 2.10
12) milk $ 1.35
13) onion rings $ 1.45
14) orange soda $ 1.25
15) pie $ 1.65
16) potato chips $ 1.50
17) salad $ 2.25
18) water $ 0.75
Which item would you like?
2
Would you like another item? (y or Y)
n
Here's your bill:
cheeseburger $ 2.75
orange soda $ 1.25
french fries $ 1.25
cheeseburger $ 2.75
Your total is $ 8.00
Thank you for eating at Goodburger!
linux2[3]%
Sample and Test Data Files
The data file that was used for the sample run above can be found in Ms. Mitchell's
public directory. The pathname is:
/afs/umbc.edu/users/s/m/smitchel/pub/CMSC202/p1/food.dat
Remember that this is a sample file only. The file(s) used to test your
program may be (and most likely will be) different. However, you have the following
guarantees regarding the file(s) used for grading:
- It will have the identical format as that of the sample data file.
- There will be at most 50 records in the file, but it may be empty.
- There will be no duplicate records in the file.
So, make sure to test your program thoroughly using your own test data file(s).
Note the following when you create a test file(s):
- The maximum length for a food item is 20 characters.
- Prices are always floating point numbers with exactly two decimal places.
Error Handling
Your program, and ALL programs in this class, must handle the following errors:
- Correct number of command line arguments
- All files were successfully opened
- Any input data files are not empty
- Any dynamic storage was successfully allocated
For this project, if any of the above errors occur, send a message to the user
(via cerr) and exit the program. We will learn other error handling techniques
later in the semester.
In addition, for this project, you must check that any menu selections made
are within bounds. If not, inform the user and redisplay the menu.
Other Notes
Your program, and ALL programs in this class, should always follow these rules:
- Don't open a data file, whether input or output, until it is needed.
- Close all data files, whether input or output, as soon as they are not needed
anymore.
- Do not use the
#define
preprocessor directive. Use the
const
statement instead.
- Use dynamic allocation for all arrays (including strings). The only exception
is when you are using a temporary string to read a data item in from a file or the
keyboard.
- Deallocate any dynamic storage as soon as it is no longer needed.
- Protect all header files with the
#ifndef
and #endif
preprocessor directives.
Project Make File
The "make" utility is used to help control projects with large numbers of files.
It consists of targets, rules, and dependencies. You will be learning about
make files in discussion. For this project, the file will be provided for you.
Copy the file
/afs/umbc.edu/users/s/m/smitchel/pub/CMSC202/p1/Makefile
to your directory. (Note that my user id has a lowercase letter "L", not the
number one as the last character.)
When you finish creating all of the required project files (proj1.C,
burger.C, and burger.H), you will find that by typing the command make
or make Proj1 at the Linux prompt, your project will compile
and link (if there are no compiler or linker errors) and produce an executable
called Proj1. In addition, typing make clean will remove any
extraneous files in your directory, such as .o files and core files.
And typing make cleanest will remove all .o files, core, Proj1,
and backup files made by the editor.
See the 202 Syllabus
for links to more information on make files.
Grading
The grade for this project will be broken down as follows:
- 70% - Correctness
- The program behaves the same way that the sample does and the code meets ALL of the
project specification.
- Note: Your program may contain AT MOST TWO LOOPS (e.g., for, while, or do-while).
However, you will receive a 5 point deduction for each loop. More than two loops
will receive a zero for the entire project.
- 10% - Design
- Your design was submitted on time.
- Your code represents a "good" top-down design that matches,
to a reasonable degree, the design that you submitted earlier.
- 20% - CMSC 202 Coding Standards and Documentation
Project Submission
You must use separate compilation for this project. You must have a file called
proj1.C
that contains the function main(). You should also have a
burger.C and a burger.H that contain the functions used by proj1.C and the
prototypes for those functions, respectively. (Note the uppercase "C" and
uppercase "H".) Submit as follows:
submit cs202_01 Proj1 proj1.C burger.C burger.H Makefile
The order in which the files are listed doesn't matter. However, you must make
sure that all files necessary to compile your project (using the make file)
are listed.
You can check to see what files you have submitted by typing
submitls cs202_01 Proj1
More complete documentation for submit and related commands can be found
here.
Remember -- if you make any change to your program, no matter how
insignificant it may seem, you should recompile and retest your program before
submitting it. Even the smallest typo can cause compiler errors and a reduction
in your grade.
Last Modified: Monday, 04-Feb-2002 11:14:14 EST