Class MultiplicationExpressionNode

  • All Implemented Interfaces:
    ExpressionNode

    public class MultiplicationExpressionNode
    extends SequenceExpressionNode
    An ExpressionNode that handles multiplications and divisions. The node can hold an arbitrary number of factors that are either multiplied or divided to the product.
    • Constructor Detail

      • MultiplicationExpressionNode

        public MultiplicationExpressionNode()
        Default constructor.
      • MultiplicationExpressionNode

        public MultiplicationExpressionNode​(ExpressionNode node,
                                            boolean positive)
        Constructor to create a multiplication with the first term already added.
        Parameters:
        node - the term to be added
        positive - a flag indicating whether the term is multiplied or divided
    • Method Detail

      • getType

        public int getType()
        Returns the type of the node, in this case ExpressionNode.MULTIPLICATION_NODE
        Returns:
        type of the node
      • getValue

        public double getValue()
        Returns the value of the sub-expression that is rooted at this node. All the terms are evaluated and multiplied or divided to the product.
        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 all the terms in the product.
        Parameters:
        visitor - the visitor