abc.notation
Class Fraction

java.lang.Object
  extended byabc.notation.Fraction
Direct Known Subclasses:
TimeSignature

public class Fraction
extends java.lang.Object

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

Fraction

public Fraction(int numeratorValue,
                int denominatorValue)
         throws java.lang.IllegalArgumentException
Creates a new fraction with the specified numerator and denominator values.

Parameters:
numeratorValue - The value of the numerator.
denominatorValue - The value of the denominator.
Throws:
java.lang.IllegalArgumentException - Thrown if the denominator is equal to 0.
Method Detail

setNumerator

public void setNumerator(int numeratorValue)
Sets the numerator of this fraction.

Parameters:
numeratorValue - The numerator of this fraction.

getNumerator

public int getNumerator()
Returns the numerator of this fraction.

Returns:
The numerator value of this fraction.

setDenominator

public void setDenominator(int denominatorValue)
                    throws java.lang.IllegalArgumentException
Parameters:
denominatorValue - The denominator of this fraction.
Throws:
java.lang.IllegalArgumentException - Thrown if the denominator is equal to 0.

getDenominator

public int getDenominator()

floatValue

public float floatValue()
Returns the float value represented by this fraction

Returns:
The fload value represented by this fraction.

multipliedBy

public float multipliedBy(Fraction fraction)
Multiplies this fraction by the specified fraction and returns the result as a float. This fraction remains unchanged.

Parameters:
fraction - A Fraction.
Returns:
The result of the multiplication of this fraction by the specified one.

toString

public java.lang.String toString()
Returns a String representation of this fraction.

Returns:
a String representation of this fraction.