Thompson Rivers University
Question 3
Lab 2 Polymorphism - SM 2025Modify the RationalNumber class from Chapter 5 so that it implements the Comparable interface. To perform the comparison, compute an equivalent floating point number from the numerator and denominator for both RationalNumber objects, and then compare them using a tolerance of 0.0001. Write a main driver to test your modifications. (Hint: The RationalNumber class and driver from Chapter 5 have been placed in the Chapter 9 directory in the “Source Code” area of your course.)
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 54 more lessons in Thompson Rivers University.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.