CSC 161 Program #4

Doubly Linked List
Assigned: Weds May 14, 2003 Due: Fri May 23, 2003
Grade: 80 points  

Concepts

The "new" concepts covered in this program are:

  • Overloading operators

  • Templates

  • The this pointer

  • Linked lists

Description

In this program, you are charged to create a doubly linked list data type.

Part A

Implement a doubly linked list for integers. You are provided with:

  • IntList.h - header file for the list
  • prog04a.cpp - a test driver for your list

You need to implement all the member functions in the list header (in IntList.cpp) and test them using the main() program that I have provided.

Part B

Implement a generic doubly linked list. You are provided with:

  • prog04b.cpp - a test driver for your list

The task here is to turn your integer list into a generic template that can be used for any data type. Once you have accomplished this, you can test your implementation with my main() test driver.

There is a restriction with our compiler that all template functions be included in the header file. You will want to cut and paste your implementation file after the definition of the DoublyLinkedList template class. 

Implementation

Of course, this program exercises your (new) knowledge of templates and linekd lists. These topics are discussed in Chapters 15 and 16, respectively, in our text.

More specifically, the really meaty/relevant sections in the book are:

  • Section 16.3 - an example of a linked list template (though our program will be a bit different this)
  • Section 16.4 - a brief intro to doubly linked lists

 


Grading

Your program will be graded on three areas: design, quality, and function. Their description and weighting in your grade is given below.

1. Program Design (25%)

It is essential to design your program before pounding it out in front of Visual C++. The design for this program requires:

  • A header each class that you design with member variables and functions defined and commented.
  • A pseudo-code description of main().

You should include all the class interface files in your main() and be able to compile, but not build (or link) because your class member functions are not yet written.

2. Program quality (25%)

I'm working on a more comprehensive style guide, but here's what I will be looking for:

  • File comments - at the top of the file, list the file name (for printing purposes), your name, the date, "CSC 161", and what the file contains
  • Class comments - describe the purpose of the class
  • Function comments - describe the purpose of each function, it's parameters and return value if any
  • Variable comments - describe the purpose of each variable
  • Block comments - describe large or complex blocks of code in your functions
  • Well-chosen names - descriptive names for classes, functions, variables, etc.
  • Proper indentation - consistent indentation, just use the built-in facilities in Visual C++, and you'll be golden.
  • Readability - nice spacing of major sections and functions, clear flow and design

3. Program function (50%)

If your program doesn't compile or link, your grade for this section will automatically be cut in half and then I'll start from there. Please leave a README file in your prog01 folder with notes you want me to read.

Good luck.

Notes

May 14, 2003

Changed some names to simplify things, and I dropped the addition operator. I posted the following on the k: drive:

  • IntList.h

  • prog04a.cpp

I still need to add "remove" tests to the prog04a driver.

Part B driver is coming soon!

May 19, 2003

The test driver for Part B is available in the Common Area:

  • prog04b.cpp

On part B, it is a requirement of the Visual C++ compiler that all the functions of a template class be in the same file as the class definition. This means that you do not want a separate DoublyLinkedList.cpp. Put your function implementations at the end of the header file DoublyLinkedList.h.

May 21, 2003

Please note that our compiler requires all the functions of a template class to reside in the header along with the definitions. So, for part B, the definition and the implementation of member functions should reside in DoublyLinkedList.h.