Class Op


  • public class Op
    extends java.lang.Object
    Represents a mathematical operation.

    Copyright 2003, Dale Anson, all rights reserved

    • Constructor Summary

      Constructors 
      Constructor Description
      Op()  
      Op​(java.lang.String op)  
      Op​(java.lang.String op, java.lang.String type)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addConfiguredNum​(Num num)
      Add a number to this operation.
      void addConfiguredOp​(Op op)
      Add a nested operation.
      Num calculate()
      Perform this operation.
      void setDatatype​(java.lang.String p)
      Sets the datatype of this calculation.
      void setOp​(java.lang.String op)
      Set the operation.
      void setStrict​(boolean b)
      Use the StrictMath library.
      • Methods inherited from class java.lang.Object

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

      • Op

        public Op()
      • Op

        public Op​(java.lang.String op)
      • Op

        public Op​(java.lang.String op,
                  java.lang.String type)
    • Method Detail

      • setOp

        public void setOp​(java.lang.String op)
        Set the operation.
      • addConfiguredNum

        public void addConfiguredNum​(Num num)
        Add a number to this operation. An operation can hold any number of numbers to support formulas like 5 + 4 + 3 + 2 + 1.
        Parameters:
        num - a number to use in this operation
      • setDatatype

        public void setDatatype​(java.lang.String p)
        Sets the datatype of this calculation. Allowed values are "int", "long", "float", or "double".
      • addConfiguredOp

        public void addConfiguredOp​(Op op)
        Add a nested operation.
        Parameters:
        op - the operation to add.
      • setStrict

        public void setStrict​(boolean b)
        Use the StrictMath library.
      • calculate

        public Num calculate()
        Perform this operation.
        Returns:
        the value resulting from the calculation as a Num.