Use assertions and exceptions to develop an implementation of Rational (see Exercise 3.2.7) that is immune to overflow.
Exercise 3.2.7
Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division.
Use Euclid.gcd() (Program 2.3.1) to ensure that the numerator and the denominator never have any common factors. Include a test client that exercises all of your methods. Do not worry about testing for integer overflow (see Exercise 3.3.17).
Program 2.3.1
Exercise 3.3.17
Use assertions and exceptions to develop an implementation of Rational (see Exercise 3.2.7) that is immune to overflow.
Exercise 3.2.7
Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division.
Use Euclid.gcd() (Program 2.3.1) to ensure that the numerator and the denominator never have any common factors. Include a test client that exercises all of your methods. Do not worry about testing for integer overflow (see Exercise 3.3.17).
Exercise 3.3.17
Use assertions and exceptions to develop an implementation of Rational (see Exercise 3.2.7) that is immune to overflow.
Exercise 3.2.7
Implement a data type Rational for rational numbers that supports addition, subtraction, multiplication, and division.
Use Euclid.gcd() (Program 2.3.1) to ensure that the numerator and the denominator never have any common factors. Include a test client that exercises all of your methods. Do not worry about testing for integer overflow (see Exercise 3.3.17).