-
Write an overloaded version of add that takes an int asparameter.
-
We have seen other classes convert a string with a static method( like Double.parseDouble). We could do the same thing in theRational class, starting from the heading
public static Rational parseRational(String s)
Note that you can take the basic logic from the Pythonconstructor.
Here’s the SortRational.java code that’s needed:
// Illustrating that the Comparable interface// allows sort to work.”’import java.util.Collections;import java.util.ArrayList;public class SortRational{ public static void printRationals(ArrayList<Rational> rList) { for (Rational r : rList)
OR
OR