Class AtomComparator
java.lang.Object
calculator.atoms.visitor.AtomVisitor
calculator.atoms.visitor.AtomComparator
AtomComparator is an AtomVisitor whose goal is to give the largest set of number
between all visited types
e.g. between an Integer, Real and Complex, the Complex type is the largest
as both the Integer and Real are included in Complexes
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreturns the most englobing type visitedvoidVisits a Complex and changes the result to complex as any Number can be converted to a complexvoidvisit(IntegerAtom i) Visits a Integer and doesn't change the result as the integer type is the smallest setvoidVisits a Rationnal and changes the result only if it was an integervoidVisits a Real and changes the result if it was a Rationnal or Integer
-
Constructor Details
-
AtomComparator
public AtomComparator()Constructor of the AtomComparator visitor
-
-
Method Details
-
getResult
returns the most englobing type visited- Returns:
- The most englobing type visited
-
visit
Visits a Real and changes the result if it was a Rationnal or Integer- Specified by:
visitin classAtomVisitor- Parameters:
r- the Real to be visited
-
visit
Visits a Complex and changes the result to complex as any Number can be converted to a complex- Specified by:
visitin classAtomVisitor- Parameters:
c- the Complex to be visited
-
visit
Visits a Rationnal and changes the result only if it was an integer- Specified by:
visitin classAtomVisitor- Parameters:
q- the Rationnal to be visited
-
visit
Visits a Integer and doesn't change the result as the integer type is the smallest set- Specified by:
visitin classAtomVisitor- Parameters:
i- the Integer to be visited
-