Next: An operator
Up: Assignment 9: Rational Numbers
Previous: Another constructor
- 1.
- Write a new method called negate that reverses the sign
of a rational number. It will look a lot like the conjugate
method of the Complex class, except that it should negate the numerator
instead of the imaginary part.
- 2.
- Add lines to main to test the new method.
- 3.
- Write a method called invert that inverts the number by
swapping the numerator and denominator. This method is also a
modifier, and should also return void. Add lines to main to test the
new method.
Allen B. Downey
4/8/1998