Question: a) Design and implement a Comparable Java class to represent a Rational number such as 3/2. Your class will have the following methods as
a) Design and implement a Comparable Java class to represent a Rational number such as 3/2. Your class will have the following methods as well as any other methods necessary (setters, getters, etc.). A constructor that takes all parameters (numerator, denominator), A function that returns the number of existing Rational objects, Override the toString method, Methods for adding and multiplying Rational objects, Your methods will throw exceptions if there are problems. b) Write another class to test your Rational class including the exceptions.
Step by Step Solution
There are 3 Steps involved in it
Here is the implementation of the Rational class in Java java import javautilArrayList import javautilList public class Rational implements Comparable ... View full answer
Get step-by-step solutions from verified subject matter experts
