Class ExponentiationExpressionNode

  • All Implemented Interfaces:
    ExpressionNode

    public class ExponentiationExpressionNode
    extends Object
    implements ExpressionNode
    An ExpressionNode that handles exponentiation. The node holds a base and an exponent and calulates base^exponent
    • Constructor Detail

      • ExponentiationExpressionNode

        public ExponentiationExpressionNode​(ExpressionNode base,
                                            ExpressionNode exponent)
        Construct the ExponentiationExpressionNode with base and exponent
        Parameters:
        base - the node containing the base
        exponent - the node containing the exponent
    • Method Detail

      • getType

        public int getType()
        Returns the type of the node, in this case ExpressionNode.EXPONENTIATION_NODE
        Specified by:
        getType in interface ExpressionNode
        Returns:
        type of the node
      • getValue

        public double getValue()
        Returns the value of the sub-expression that is rooted at this node. Calculates base^exponent
        Specified by:
        getValue in interface ExpressionNode
        Returns:
        value of expression
      • accept

        public void accept​(ExpressionNodeVisitor visitor)
        Implementation of the visitor design pattern. Calls visit on the visitor and then passes the visitor on to the accept method of the base and the exponent.
        Specified by:
        accept in interface ExpressionNode
        Parameters:
        visitor - the visitor