|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabc.notation.Fraction
This class enables the representation of a fraction.
Constructor Summary | |
Fraction(int numeratorValue,
int denominatorValue)
Creates a new fraction with the specified numerator and denominator values. |
Method Summary | |
float |
floatValue()
Returns the float value represented by this fraction |
int |
getDenominator()
|
int |
getNumerator()
Returns the numerator of this fraction. |
float |
multipliedBy(Fraction fraction)
Multiplies this fraction by the specified fraction and returns the result as a float. |
void |
setDenominator(int denominatorValue)
|
void |
setNumerator(int numeratorValue)
Sets the numerator of this fraction. |
java.lang.String |
toString()
Returns a String representation of this fraction. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Fraction(int numeratorValue, int denominatorValue) throws java.lang.IllegalArgumentException
numeratorValue
- The value of the numerator.denominatorValue
- The value of the denominator.
java.lang.IllegalArgumentException
- Thrown if the denominator is equal
to 0.Method Detail |
public void setNumerator(int numeratorValue)
numeratorValue
- The numerator of this fraction.public int getNumerator()
public void setDenominator(int denominatorValue) throws java.lang.IllegalArgumentException
denominatorValue
- The denominator of this fraction.
java.lang.IllegalArgumentException
- Thrown if the denominator is equal
to 0.public int getDenominator()
public float floatValue()
public float multipliedBy(Fraction fraction)
fraction
- A Fraction.
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |