CIT 597 Assignment 9: Fractions and Unit Testing
Fall 2008, David Matuszek

Purpose of this assignment:

General idea:

Implement a Fraction class. Write tests for it.

Because this is a very short assignment, it will be worth 25 points instead of the usual 100 points.

Programming details:


Implement a Fraction class. It should have:

All fractions should automatically be kept in lowest terms. For example, if you construct a fraction with f = 8, 12, you will get the fraction 2/3. Likewise, if you add 1/4 and 1/4, you should get 1/2. Also, there is nothing wrong with so-called "improper" fractions (fractions greater than 1, such as 7/3); they are perfectly good fractions.

To keep this assignment simple, you don't have to worry about negative numbers.


Implement a FractionTest class containing unit tests for each of the four arithmetic methods, and a test for the constructor. You can test the constructor by testing, for example, whether 8, 12 is equal to 2/3.

Due date:

Wednesday, November 26, by midnight. Submit, via Blackboard, one file named fractions.rb (you can put both classes into this one file).