Methods Summary |
---|
public boolean | equals(java.lang.Object obj)
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (obj instanceof Rational) {
Rational data = (Rational) obj;
return mNumerator == data.mNumerator && mDenominator == data.mDenominator;
}
return false;
|
public long | getDenominator()Gets the denominator of the rational
return mDenominator;
|
public long | getNumerator()Gets the numerator of the rational.
return mNumerator;
|
public double | toDouble()Gets the rational value as type double. Will cause a divide-by-zero error
if the denominator is 0.
return mNumerator / (double) mDenominator;
|
public java.lang.String | toString()
return mNumerator + "/" + mDenominator;
|