CS 14 - Lab 3


CS 14 Homepage

ADT Counter

Remember, in this course, all programming will be done under the Linux operating system, using standard programming tools for that environment. Linux is a free operating system, available for all to download (RH), (Mandrake) and use with no cost. Linux itself is about a decade old, but in conjunction with a set of free utilities from the GNU project, behaves like a member of the UNIX family of operating systems.

Tutorials on Linux are available all over the Internet, Google for "Linux tutorial" and find one that suits you, or just try this one.

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.h 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 1: your class should be derived publicly from Counter, and should use exceptions to signal error. Errors occur whenever the value of Couter would be outside the bounds it was created with. Throwing the exception std::domain_error is as a good choice as any for now.

Hint 2: you know if your file is correct if testcounter.cc returns only the expected exceptions.

Save your file as simplecounter.cc.



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 Course Style Guide before starting the program.

Lab Grading

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


© 2003 UC Riverside Department of Computer Science & Engineering. All rights reserved.