Class Rationnal
java.lang.Object
calculator.atoms.Rationnal
- All Implemented Interfaces:
Atom, Expression
-
Constructor Summary
ConstructorsConstructorDescriptionRationnal(int value) Constructor method for a whole number * @param value The integer value (e.g., 5 becomes 5/1)Rationnal(int numerator, int denominator) Constructor method * @param numerator The numeratorRationnal(org.apache.commons.numbers.fraction.Fraction value) Constructor method from an existing Fraction object * @param value The commons-numbers Fraction object -
Method Summary
Modifier and TypeMethodDescriptionvoidaccepts the specific AtomVisitorvoidaccept is a method needed to implement the visitor design patternapply(BinaryFunction f, Atom a) Applies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete typeApplies an operation on the atomApplies an operation between two atoms of the same concrete type The function supposes that both atoms are of the same concrete typebooleanintintorg.apache.commons.numbers.fraction.FractiongetValue()getter method to obtain the value contained in the objectinthashCode()toString()
-
Constructor Details
-
Rationnal
public Rationnal(int numerator, int denominator) Constructor method * @param numerator The numerator- Parameters:
denominator- The denominator
-
Rationnal
public Rationnal(int value) Constructor method for a whole number * @param value The integer value (e.g., 5 becomes 5/1) -
Rationnal
public Rationnal(org.apache.commons.numbers.fraction.Fraction value) Constructor method from an existing Fraction object * @param value The commons-numbers Fraction object
-
-
Method Details
-
getValue
public org.apache.commons.numbers.fraction.Fraction getValue()getter method to obtain the value contained in the object- Returns:
- The commons-numbers Fraction number contained in the object
-
apply
Description copied from interface:AtomApplies an operation between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type -
apply
Description copied from interface:AtomApplies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type -
apply
Description copied from interface:AtomApplies an operation on the atom -
accept
Description copied from interface:Atomaccepts the specific AtomVisitor -
accept
Description copied from interface:Expressionaccept is a method needed to implement the visitor design pattern- Specified by:
acceptin interfaceExpression- Parameters:
v- The visitor object being passed as a parameter
-
equals
-
hashCode
-
getNumerator
public int getNumerator() -
getDenominator
public int getDenominator() -
toString
-