HOME | Overview | Syllabus | Instructor | Lectures | Laboratories | Readings | Assignments | Resources | Other Links
CS 1713 Lecture 10: Designing a Class From a Specification
September 22, 1999

In this class period we will code and test a class specification called Fraction that implements a rational number. A rational number is defined as the ratio of two integers, a numerator and denominator. The Fraction class can print itself in the form a/b. It can also give its value in decimal. Other operations that the Fraction can perform are:

All of these operations change the Fraction's value.

When reading the specification it is a good idea to work out some examples prior to actually designing the class. Then try to answer these questions:

Once you have a fairly good idea of the design, you should implement in stages:

Think about: What if denominator is zero?

The code developed in class can be found here

Quick Check Problems:


Objective: Design and test a class from a specification.
Last revision: September 23, 1999 at 8:30 am