Class Evaluator


public class Evaluator extends Visitor
Evaluation is a concrete visitor that serves to compute and evaluate the results of arithmetic expressions.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor of the class.
  • Method Summary

    Modifier and Type
    Method
    Description
    getter method to obtain the result of the evaluation
    void
    The Visitor can traverse a Complex number (a subtype of Expression)
    void
    The Visitor can traverse an Integer (a subtype of Expression)
    void
    The Visitor can traverse a Rationnal number (a subtype of Expression)
    void
    Use the visitor design pattern to visit a Real.
    void
    The Visitor can traverse a binary function (a subtype of Expression)
    void
    The Visitor can traverse an unary function (a subtype of Expression)
    void
    Use the visitor design pattern to visit an operation

    Methods inherited from class Object

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

    • Evaluator

      public Evaluator()
      Default constructor of the class. Does not initialise anything.
  • Method Details

    • getResult

      public Atom getResult()
      getter method to obtain the result of the evaluation
      Returns:
      an Integer object containing the result of the evaluation
    • visit

      public void visit(Real r)
      Use the visitor design pattern to visit a Real.
      Specified by:
      visit in class Visitor
      Parameters:
      r - The Real being visited
    • visit

      public void visit(IntegerAtom i)
      Description copied from class: Visitor
      The Visitor can traverse an Integer (a subtype of Expression)
      Specified by:
      visit in class Visitor
      Parameters:
      i - The operation being visited
    • visit

      public void visit(Complex c)
      Description copied from class: Visitor
      The Visitor can traverse a Complex number (a subtype of Expression)
      Specified by:
      visit in class Visitor
      Parameters:
      c - The Real number being visited
    • visit

      public void visit(Rationnal q)
      Description copied from class: Visitor
      The Visitor can traverse a Rationnal number (a subtype of Expression)
      Specified by:
      visit in class Visitor
      Parameters:
      q - The Real number being visited
    • visit

      public void visit(Operation o)
      Use the visitor design pattern to visit an operation
      Specified by:
      visit in class Visitor
      Parameters:
      o - The operation being visited
    • visit

      public void visit(UnaryFunction o)
      Description copied from class: Visitor
      The Visitor can traverse an unary function (a subtype of Expression)
      Specified by:
      visit in class Visitor
      Parameters:
      o - The unary function being visited
    • visit

      public void visit(BinaryFunction f)
      Description copied from class: Visitor
      The Visitor can traverse a binary function (a subtype of Expression)
      Specified by:
      visit in class Visitor
      Parameters:
      f - The binary function being visited