Class AtomComparator

java.lang.Object
calculator.atoms.visitor.AtomVisitor
calculator.atoms.visitor.AtomComparator

public class AtomComparator extends AtomVisitor
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
    Constructor
    Description
    Constructor of the AtomComparator visitor
  • Method Summary

    Modifier and Type
    Method
    Description
    returns the most englobing type visited
    void
    Visits a Complex and changes the result to complex as any Number can be converted to a complex
    void
    Visits a Integer and doesn't change the result as the integer type is the smallest set
    void
    Visits a Rationnal and changes the result only if it was an integer
    void
    Visits a Real and changes the result if it was a Rationnal or Integer

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AtomComparator

      public AtomComparator()
      Constructor of the AtomComparator visitor
  • Method Details

    • getResult

      public AtomType getResult()
      returns the most englobing type visited
      Returns:
      The most englobing type visited
    • visit

      public void visit(Real r)
      Visits a Real and changes the result if it was a Rationnal or Integer
      Specified by:
      visit in class AtomVisitor
      Parameters:
      r - the Real to be visited
    • visit

      public void visit(Complex c)
      Visits a Complex and changes the result to complex as any Number can be converted to a complex
      Specified by:
      visit in class AtomVisitor
      Parameters:
      c - the Complex to be visited
    • visit

      public void visit(Rationnal q)
      Visits a Rationnal and changes the result only if it was an integer
      Specified by:
      visit in class AtomVisitor
      Parameters:
      q - the Rationnal to be visited
    • visit

      public void visit(IntegerAtom i)
      Visits a Integer and doesn't change the result as the integer type is the smallest set
      Specified by:
      visit in class AtomVisitor
      Parameters:
      i - the Integer to be visited