code: public Rational add(Rational value)
      {
          if (denominator == value.getDenominator())
          {
              return new Rational(numerator + value.getNumerator(), denominator);
          }
          else
          {
              return new Rational(numerator * value.getDenominator() + value.getNumerator() * denominator,
                                  denominator * value.getDenominator());
          }
      }
docs: Add the specified value to this value and return the result as a new object
  (also a rational).  If the two values have different denominators, they will
  first be converted so that they have common denominators.
  @param value The value to add to this rational.
  @return A new rational value that is the sum of this value and the specified
  value.