UCR CS 14: Introduction to Data Structures and Algorithms

Summer Quarter 2003 / Class webpage




Lab 02

In this lab, we will work with ADTs (Abstract Data Type) and debugging. The main exercise (7 points) requires you to develop a simple class using a given ADT. The other exercises require you to work with debugging and error corrections.

A file name is specified for each exercise. Save all files in the folder that you will turnin at the end of the class.



Turn-in

7 points possible

First, you have to download the files Counter and testcounter.cc.

Counter defines an abstract base class describing the interface of the abstract data type (ADT) Counter, which is (in turn) partially described in comments. The program testcounter tries to create an object of the class SimpleCounter implementing the Counter interface.

Your task is to develop a class SimpleCounter that passes the tests performed in testcounter.cc.

In other words, you have Counter as abstract class, whose implementation is done by subclasses, as for instance SimpleCounter. Also, you have a separate program (testcounter) that uses the same abstract data type by its implementation class.

Hint: your class should be derived publicly from Counter.

Hint: You will want your program to have some method to indicate when a counter has exceeded its valid range. This can range from terminating the program with an error message to printing a warning message and continuing to adding an "invalid" flag to the counter which gets set on error conditions. This implementation is left up to you.

Save your file as SimpleCounter.



Miscellaneous Tasks

1 point possible

Attendance for the full lab period is mandatory. Try working on some of the following short tasks. Each exercise is worth 0.5 points, out of 1 possible.



Bonus, more 0.4 points

Remember to read the Coding Standards before starting the program.

Lab Grading

Attendance - 2 points
Counter implementation turned in - 7 points
Misc. Tasks - 1 point
Extra credit - .4 points
Total: 10.4/10