Write Overloaded Version Add Takes Int Parameter Seen Classes Convert String Static Method Q37273575

  1. Write an overloaded version of add that takes an int asparameter.

  2. 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

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.