CPS 108: Class Design Problem
Spring 1999
Due at the end of class.
Form groups of size three or four persons. You may not work alone! You
should start this group activity by introducing each member of the group.
You may also want to choose one person to write down the group's discussion
on the given foil as you go.
There are three parts to this activity:
-
Developing an interface for a class that behaves like a Pascal Array (i.e.,
what are the semantics of using your class)
-
Writing a variety of test or "use" cases to show how the class works
-
Writing code the implements the class' interface
After each part, we will re-group with the entire class and discuss the
different options to arrive at a class-wide standard.
The Pascal Array Class
You are to design an interface (i.e., the set of public methods) for a
class that implements the features of a Pascal-like array. For those
of you unfamiliar with that programming language, arrays in Pascal differ
from C-like arrays in that they can be initialized with upper and lower
bounds. Additionally, attempts to index Pascal arrays are checked by the
system to ensure that they are within the given bounds.
Your class should implement at least the features described above.
Anything you add should make your class easier to use in C++. Pay
special attention to what constructors you provide and what operators you
overload. For each public method you create, clearly describe its
semantics (or pre- and post-conditions) and why you think it should be
included. Your justification can reference Meyers, an example of
common C++ practice, or some other description.
Your first order of business is to decide on your class' name.
Example Cases
You are to develop a set of test cases for the Pascal array class ratified
by the class. For each test case, you should describe what the case
is (i.e., a one-sentence English description of the case's purpose), what
code it tests and, most importantly, the test's expected results.
Code
Finally, you are to code the methods from the Pascal array class ratified
by the class. Your code should be "Meyers compliant" and pass any
of the test cases agreed upon by the class that exercise it. You
must turn in proof that you hand-simulated your code with these test cases.