Property List Project, Part 1

Introduction

This assignment is being done as two separate homeworks. The first half is called "Homework 5a" and is due on the day of the sixth class of the course (10/8; 10/11). The second half is called "Homework 5b" and is due the week after the exam (10/29; 10/25). [The Tuesday due date was changed to 10/15, even though there is no class that day.]

The project is to develop a package that implements a structure called a "Property List." A property list is a list of elements, each of which consists of a name, a type, and a value. Within a property list, the same name may occur multiple times, but each name-type combination must be unique. The operations defined for a property list include insert, which adds an element to the list, delete, which removes an element from the list, and getValue, which retrieves a value given a name and type.

Homework 5a is to implement the first part of an interactive program that allows a user to insert entries into a property list. Homework 5b is to implement the property list package itself.

Homework 5a

Write a program containing a function definition for main(). The program prompts the user to enter a name or a command. If the string entered is "exit" the program terminates. Otherwise, the program asks the user to enter the name of a data type. Valid responses are "int," "char," "long," "float," and "double." Depending on the type name the user enters, the program then prompts for and reads in a value of the appropriate type. The program then inserts the {name-type-value} triple into the property list, and prompts the user to enter another name or command. The process repeats until the user enters "exit" in reply to the name or command prompt.

Here is an example of the execution of this program (named plist in this example):

  qcunix1> plist
  Enter name or command: vickery
  Enter type of value: int
  Enter integer value: 100
  Integer insert: vickery 100
  Insert succeeded
  Enter name or command: vickery
  Enter type of value: float
  Enter float value: 3.14159  
  Float insert: vickery 3.14159
  Insert succeeded
  Enter name or command: exit
  qcunix1> 
For this part of the assignment, I am providing you with an object module named plist.o which contains the code for a set of functions named insert(), one for each of the recognized data types. I am also providing you with a header file named plist.h that contains function prototypes for the insert() functions and a definition for an enum called types.

In the sample output above, the messages that start "Integer insert" and "Float insert" were output by the code in plist.o and all other messages were output by main().

To do this part of the project, create a project directory, change to it, and copy all the files from ~vickery/CS-200/Homework_5 into it:

  qcunix1> cp ~vickery/CS-200/Homework_5/* .
You will get one .o file, one .h file, and a Makefile. If you name your own program file main.cc, all you need to do to build an executable program named plist is to type "gmake" (no arguments needed).

You can type "gmake clean" to delete unneeded files from the project directory before you submit it.

Notes:

Homework 5b

Don't work on this part of the assignment yet. There is a Separate Web Page for it.



Dr. Christopher Vickery
Computer Science Department
Queens College of CUNY
Home Page