Package parser

Class BinaryOperator

java.lang.Object
parser.Operator
parser.BinaryOperator
All Implemented Interfaces:
Validatable
Direct Known Subclasses:
AdditionOperator, CombinationOperator, DivisionOperator, MultiplicationOperator, PermutationOperator, PowerOperator, RemainderOperator, SubtractionOperator

public class BinaryOperator
extends Operator
implements Validatable
Author:
GBEMIRO
  • Constructor Details

    • BinaryOperator

      public BinaryOperator​(java.lang.String name, int index, java.util.ArrayList<java.lang.String> scan)
      Parameters:
      name - The bame of the operator
      index - The index of the operator
      scan - The scanner output
  • Method Details

    • getPrecedence

      public Precedence getPrecedence()
      Returns:
      the precedence of this operator
    • setIndex

      public void setIndex​(int index, java.util.ArrayList<java.lang.String> scan)
      Parameters:
      index - sets the index of this operator in the scanned Function that it belongs to.
      scan - The Function object that this object exists in.
    • getIndex

      public int getIndex()
      Returns:
      the index of this operator in the scanned Function that it belongs to.
    • validate

      public boolean validate​(java.util.ArrayList<java.lang.String> scan)
      Specified by:
      validate in interface Validatable
      Parameters:
      scan - the Function object that this BinaryOperator object exists in. validates the grammatical usage of this operator (by leaving the correctFunction attribute of the function object un-modified) if the usage of this operator in its immediate environment i.e to its left and right is correct.
      Returns:
      true if valid