Package parser

Class Variable


  • public class Variable
    extends java.lang.Object
    Author:
    GBENRO template for modeling/creating variable objects
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Variable ans
      The last answer variable used for flexibility on computational systems.
      static Variable e  
      static Variable PI
      The constant PI
    • Constructor Summary

      Constructors 
      Constructor Description
      Variable​(java.lang.String name)  
      Variable​(java.lang.String name, double value, boolean constant)  
      Variable​(java.lang.String name, java.lang.String value, boolean constant)  
      Variable​(java.lang.String name, java.lang.String fullName, java.lang.String value, boolean constant)  
    • Method Summary

      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getFullName()  
      java.lang.String getName()  
      java.lang.String getSerialize()  
      int getSimpleVarIndex()  
      static int getSimpleVarIndex​(java.lang.String var)  
      static java.lang.String getSystemConstantValue​(java.lang.String name)  
      java.lang.String getUnits()  
      java.lang.String getValue()
      returns the value of the variable
      boolean isConstant()  
      static boolean isExpNumber​(java.lang.String str)  
      static boolean isLastEvaluatedAnswer​(java.lang.String str)  
      static boolean isPI​(java.lang.String str)  
      boolean isSimpleVar()  
      static boolean isSystemConstant​(java.lang.String str)  
      static boolean isSystemVar​(java.lang.String str)  
      boolean isTheta()  
      static boolean isTheta​(java.lang.String str)  
      static boolean isVariableBeginner​(java.lang.String var)  
      static boolean isVariableBuilder​(java.lang.String unit)  
      static boolean isVariableString​(java.lang.String var)
      If the name is a string of alphabets and is not an operator name, then it is a valid variable name.
      static void main​(java.lang.String[] args)  
      static Variable parse​(java.lang.String json)  
      void setConstant​(boolean constant)
      sets the nature of the Variable object to either Variable or constant
      void setFullName​(java.lang.String fullName)  
      void setName​(java.lang.String name)  
      void setUnits​(java.lang.String units)  
      void setValue​(java.lang.String value)
      changes the value stored in the variable
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • PI

        public static final Variable PI
        The constant PI
      • ans

        public static Variable ans
        The last answer variable used for flexibility on computational systems.
    • Constructor Detail

      • Variable

        public Variable​(java.lang.String name)
      • Variable

        public Variable​(java.lang.String name,
                        java.lang.String value,
                        boolean constant)
        Parameters:
        name - the name of the Variable object e.g A,B...e.t.c
        value - the value stored by the Variable object
        constant - the nature of the Variable object whether it is modifiable or not. If constant = true , then the Variable object represents a constant, whose value cannot be altered.Else,it represents a Variable object whose value can change.
      • Variable

        public Variable​(java.lang.String name,
                        java.lang.String fullName,
                        java.lang.String value,
                        boolean constant)
        Parameters:
        name - the name of the Variable object e.g A,B...e.t.c
        fullName - the full name of the Variable object
        value - the value stored by the Variable object
        constant - the nature of the Variable object whether it is modifiable or not. If constant = true , then the Variable object represents a constant, whose value cannot be altered.Else,it represents a Variable object whose value can change.
      • Variable

        public Variable​(java.lang.String name,
                        double value,
                        boolean constant)
        Parameters:
        name - the name of the Variable object e.g A,B...e.t.c
        value - the value stored by the Variable object
        constant - the nature of the Variable object whether it is modifiable or not. If constant = true , then the Variable object represents a constant, whose value cannot be altered.Else,it represents a Variable object whose value can change.
    • Method Detail

      • setFullName

        public void setFullName​(java.lang.String fullName)
      • getFullName

        public java.lang.String getFullName()
      • isConstant

        public boolean isConstant()
        Returns:
        true if the Variable object is a constant.
      • setConstant

        public void setConstant​(boolean constant)
        sets the nature of the Variable object to either Variable or constant
        Parameters:
        constant - = true if the Variable object is to be changed into a constant and constant = false if the Variable object is to be changed into a Variable object
      • isTheta

        public boolean isTheta()
      • isVariableBeginner

        public static boolean isVariableBeginner​(java.lang.String var)
        Parameters:
        var -
        Returns:
        true if the variable is a valid Variable starting character
      • isVariableString

        public static boolean isVariableString​(java.lang.String var)
        If the name is a string of alphabets and is not an operator name, then it is a valid variable name. If the name is alphanumeric,it is a valid variable name.
        Parameters:
        var - the string to check.
        Returns:
        true if the variable is a valid Variable object name.
      • isVariableBuilder

        public static boolean isVariableBuilder​(java.lang.String unit)
      • isSystemVar

        public static boolean isSystemVar​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is one that is already defined by the parser for its own purposes. An example of such a variable is any constant parameter recognized by the parser, i.e to which the parser has attached a meaning already. Also any parameter such as the "ans" parameter which returns the last value calculated by the parser is regarded by the parser to be a system variable.
      • isSystemConstant

        public static boolean isSystemConstant​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is a constant one that is already defined by the parser for its own purposes. An example of such a constant is any constant defined by the parser e.g PI and so on.
      • getSystemConstantValue

        public static java.lang.String getSystemConstantValue​(java.lang.String name)
        Parameters:
        name - the name of the system constant
        Returns:
        the constant value associated with it.
      • isExpNumber

        public static boolean isExpNumber​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is ë
      • isPI

        public static boolean isPI​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is PI
      • isTheta

        public static boolean isTheta​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is theta
      • isLastEvaluatedAnswer

        public static boolean isLastEvaluatedAnswer​(java.lang.String str)
        Parameters:
        str - the name of the String variable
        Returns:
        true if the variable is the last result evaluated
      • isSimpleVar

        public boolean isSimpleVar()
        Returns:
        true if the variable is a simple one i.e A-Z or theta
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name - mutator method that changes the value of the variable
      • getName

        public java.lang.String getName()
        Returns:
        the String property of the variable
      • setValue

        public void setValue​(java.lang.String value)
        changes the value stored in the variable
        Parameters:
        value - The value to be stored Sometimes the value contains a unit. To support this, the user should place a space between the value and the units.
      • getValue

        public java.lang.String getValue()
        returns the value of the variable
        Returns:
        the value stored in the variable
      • setUnits

        public void setUnits​(java.lang.String units)
      • getUnits

        public java.lang.String getUnits()
      • getSimpleVarIndex

        public static int getSimpleVarIndex​(java.lang.String var)
        Parameters:
        var - the String property of the variable.This method returns the index of the Variable object that has this String property.
        Returns:
        The index of the Variable object that has this String property.
      • getSimpleVarIndex

        public int getSimpleVarIndex()
        Returns:
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • parse

        public static Variable parse​(java.lang.String json)
      • getSerialize

        public java.lang.String getSerialize()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • main

        public static void main​(java.lang.String[] args)
        Parameters:
        args -