Lab07, CISC181, Spring 2005

This lab introduces "linked lists"

In this lab you will first work through some source code examples provided by the instructor to understand how to work with linked lists both with and without classes. This code will be explained in lecture.

Then you will develop your own program, with very little hand-holding. I will explain briefly the purpose of the program, but it will be up to you to develop the details. You should work independently, not collaborating with other students, except perhaps at the level of clarifying the instructions. However, you must NOT share code, look at each others code, or discuss details of code.

Step 1: Work through the code in the lab07 subdirectory

There is nothing to turn in for this step. In fact, you could skip it altogether, though I don't recommend that!

What you need to do is to copy the entire lab07 subdirectory into your account, and then try to compile and run each of the programs one at at time, starting with the code in 01.structs. This code shows an example of how to build a linked list using structs. Compile and run the code, and try to understand what each line is doing.

Then work through 02.classesWithEmbeddedStructs. Under this directory, there are several sub-directories. Each of which contains a later stage in the development of this code. Try to understand what is happening at each stage. At some stages, the code does not compile. Try to understand why. If the code doesn't compile, a later version will fix the error. Try to understand why the change fixed the problem.

Step 2: Create your own program that allows a user to "look up the prices of menu items".

Write a program that

(1) reads a file of menu items (e.g. menu items from a restaurant), listing items and prices

(2) prompts the user to enter menu items, and displays the prices of those items.

The file of menu items should be comma separated. For example:

12" cheese pizza, 5.95
16" cheese pizza, 9.95
Pasta Primavera, 8.95
Vegetable Lasagna, 10.95
Ice Tea,1.95
Coca Cola,1.50

After reading the file, you should go into a loop where you prompt the user for a product. The user enters, for example:

12" cheese pizza

The program should then print:

Price of a 12" cheese pizza is $5.95

or

The item 12" cheese pizza was not found.

You should follow the example code given for ideas about how to structure your code. Ideally, the linked list should be wrapped up inside a class, following the last example given under "02.structsWithEmbeddedClasses". You should develop a Makefile that includes a "make all" and a "make clean" rule.

Submission:

Turn in a tar file that contains no .o or executable files; only your source code (.h and .cc files), your data file (e.g. menu.dat) and a Makefile that includes a make all and make clean rule.

Grading:

Style: 40 pts
Correctness: 40 pts
Following Instructions: 20 pts

***end of assignment***