Class Variable
java.lang.Object
parser.Variable
- All Implemented Interfaces:
Savable, Serializable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
getName()
int
static int
getSimpleVarIndex
(String var) static String
getSystemConstantValue
(String name) getType()
getUnits()
getValue()
returns the value of the variableboolean
static boolean
isExpNumber
(String str) static boolean
static boolean
boolean
static boolean
isSystemConstant
(String str) static boolean
isSystemVar
(String str) boolean
isTheta()
static boolean
static boolean
isVariableBeginner
(String var) static boolean
isVariableBuilder
(String unit) static boolean
isVariableString
(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
static Variable
void
setConstant
(boolean constant) sets the nature of the Variable object to either Variable or constantvoid
setFullName
(String fullName) void
void
void
void
changes the value stored in the variabletoString()
-
Field Details
-
name
-
type
-
value
-
units
-
constant
private boolean constant -
fullName
The full name of the variable -
PI
The constant PI -
ans
The last answer variable used for flexibility on computational systems. -
e
-
-
Constructor Details
-
Variable
-
Variable
- Parameters:
name
- the name of the Variable object e.g A,B...e.t.cvalue
- the value stored by the Variable objectconstant
- 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
- Parameters:
name
- the name of the Variable object e.g A,B...e.t.cfullName
- the full name of the Variable objectvalue
- the value stored by the Variable objectconstant
- 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
- Parameters:
name
- the name of the Variable object e.g A,B...e.t.cvalue
- the value stored by the Variable objectconstant
- 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 Details
-
setType
-
getType
-
setFullName
-
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
- Parameters:
var
-- Returns:
- true if the variable is a valid Variable starting character
-
isVariableString
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
-
isSystemVar
- 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
- 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
-
isExpNumber
- Parameters:
str
- the name of the String variable- Returns:
- true if the variable is ë
-
isPI
- Parameters:
str
- the name of the String variable- Returns:
- true if the variable is PI
-
isTheta
- Parameters:
str
- the name of the String variable- Returns:
- true if the variable is theta
-
isLastEvaluatedAnswer
- 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
- Parameters:
name
- mutator method that changes the name of the variable
-
getName
- Returns:
- the String property of the variable
-
setValue
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
returns the value of the variable- Returns:
- the value stored in the variable
-
setUnits
-
getUnits
-
getSimpleVarIndex
- 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
-
parse
-
serialize
-
toString
-
main
- Parameters:
args
-
-