CS 12, Fall 2008
Assignment 3

This project is mostly designed to help you learn about abstraction, and to give you some practice testing an abstract data type (ADT).

Copies of all necessary files are in ~mikec/cs12/hw3/ at CSIL:
basiclist.h, basiclist.c, *testlist (executable solution that cannot be copied), and testlist-incomplete.dat

Due Friday, November 14, 9:00pm

  1. Type answers to the following Review Questions from the Standish text into a plain text file named hw3.txt. Type your name and the current date at the top of this file, and number your answers to correspond with the problem numbers in the textbook.
  2. Write a program and a related Makefile for testing basiclist.c, an implementation of this basic list ADT: basiclist.h. Make copies of these files in your working directory for this project, and study them.
    1. Write testlist.c with the following specifications.
      • Do not prompt for input. Read commands from stdin until EOF or the quit is encountered. Respond to each command by one line of output (preferably exactly) as shown in this sample run from our solution. Never terminate abnormally (i.e., don't crash under any circumstances).
      • Ignore blank lines and comment lines. A comment line is one where the '#' is its first non-blank character. This feature will be used in part 3.
      • Valid commands {and position specifiers} are:
        • insert followed by one of { first, last, before, after } followed by a third item (the string to be inserted to the list);
        • delete followed by one of { first, last, current };
        • show followed by one of { first, last, current, all };
        • clear, advance, reset and quit.
        Any other input is an input error (except blank lines and comment lines).
      • Of course you should #include "basiclist.h" and use those functions to execute the commands.
      • See the sample run, and also run the executable version of our solution yourself (at CSIL) to know how the program should respond to these commands. [Note: if your results match our results exactly, then it will be easy for the grader to notice your results are perfect.] In the sample run, the last five requests before quit are input errors, and the user entered two comment lines and a blank line just before the errors.
    2. Also create a Makefile, named Makefile to separately compile testlist.c and basiclist.c, and properly link them to produce an executable file named testlist. Include comments (first character is '#') at the top identifying you and the date (just like everything else you turn in).
  3. Finally, create a file called testlist.dat containing commands that completely test all of the ADT functions and the operation of your testing program. Use comment lines and blank lines as necessary to clearly communicate the logic of your testing plan.
  4. Test everything at CSIL. Then turn in the four required files at once from your engineering account as follows:
    turnin hw3@cs12 hw3.txt testlist.c Makefile testlist.dat
    Late projects may not be accepted.

Updated 10/28/08 by C. Michael Costanzo