Class StandardFunction

java.lang.Object
edu.hws.jcm.data.StandardFunction
All Implemented Interfaces:
MathObject, Serializable

public class StandardFunction extends Object implements MathObject
This class exists to associate standard functions, such as sin and abs, with their names. Note that the functions are actually implemented in the ExprsssionProgram class, where they are only represented by numerical operation codes. An object of type StandardFunction contains a name and the operation code of the associated standard function. A static routine, standardFunctionName, gives the name associated with each operation code.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    StandardFunction(int opCode)
    Create a StandardFunction object to represent the standard function with the given operation code, where opCode is one of the codes for standard functions defined in class ExpressionProgram.
    StandardFunction(String name, int opCode)
    Create a StandardFunction object to represent the standard function with the given operation code, where opCode is one of the codes for stadard functions defined in class ExpressionProgram.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the name of this StandardFunction oject.
    int
    Return the operation code for this standard function.
    void
    Change the name of this StandardFunction.
    static String
    Return the usual name for the standard function with the specified opCode.

    Methods inherited from class java.lang.Object

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

    • StandardFunction

      public StandardFunction(int opCode)
      Create a StandardFunction object to represent the standard function with the given operation code, where opCode is one of the codes for standard functions defined in class ExpressionProgram. The name is the one associated with the opCode by the static function standardFunctionName() in this class. An error will occur if opCode is not one of the valid standard function operation codes.
    • StandardFunction

      public StandardFunction(String name, int opCode)
      Create a StandardFunction object to represent the standard function with the given operation code, where opCode is one of the codes for stadard functions defined in class ExpressionProgram. Use the specified name for the standard function. This allows you to make alternative names, such as "log" instead of "log10". An error will occur if opCode is not one of the valid standard function operation codes.
  • Method Details

    • getOpCode

      public int getOpCode()
      Return the operation code for this standard function.
    • getName

      public String getName()
      Return the name of this StandardFunction oject.
      Specified by:
      getName in interface MathObject
    • setName

      public void setName(String name)
      Change the name of this StandardFunction. This shouldn't be done if this object is registered with a Parser.
      Specified by:
      setName in interface MathObject
    • standardFunctionName

      public static String standardFunctionName(int opCode)
      Return the usual name for the standard function with the specified opCode. The opcodes are defined in the ExpressionProgram class. Will throw an IllegalArgumentException if the specified oPcode is not the opcode for any standard function.