CS 114B - Spring 1996 - Project 1
Preliminary ADT due date - February 28, 1996
Project due date - March 15, 1996
Built into C++ are the numerical types int and float, as well as variants such as long, short, and double. The language does not, however, include a representation for fractions. For this project you will create a Fraction ADT and implement and test a corresponding C++ class.
The essential data members will be a numerator and a denominator. Data members are to be kept private. Operation are to include:
This list is not exhaustive. You will most probably want some others as well, especially ``helper'' functions for some of the above.
Your preliminary task is to type up an ADT specification for Fraction, analogous to the SeqList specification given on pp 16-18 of Ford & Topp. You will then declare and implement the ADT in C++. You may prefer to define many of the binary operators outside the actual Fraction class, since they are not methods for accessing/manipulating a single object of type Fraction, but manipulate pairs of Fractions. You may, of course, make them part of the class, so that they work on a current object and an additional parameter. Either way, they should be included in the ADT you write.
As you develop operators, you should test them by calling them with a variety of data. Your main function can serve as ``driver'' for testing/debugging purposes. Closer to the due date, you will be provided with a specific series of tests to run.
What to hand in: on 2/28, your ADT specification in English. On 3/15, your documented source code, a script of your program running the assigned tests, a manual (especially, your English ADT, plus any additional information that might be useful, e.g., information on error handling, description of complex algorithms, if any, and information on which functions use which others), and a log of your programming exercise.
Focus of the project: is the creation of a class of objects. You are creating a (mock) library file such as string.h that could be useful to other programs. Your main function will just act as a driver, passing specified test messages to Fraction objects. Do not spend a lot of time concocting an elaborate main function.