Package math.tartaglia
Class TartagliaExpressionParser
java.lang.Object
math.tartaglia.TartagliaExpressionParser
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
When the situation x+2y+z=9; is met, this method will convert it into 1.0x+2y+z=9;void
This method initializes the coefficients field with the coefficient of Xsquared at index 0 the coefficient of X at index 1 the coefficient of the constant term at index 2void
removes white space from the ArrayListprivate int
indexOfLetter
(String input) boolean
isValid()
static void
private void
Handles consecutive strings of plus and minus operators and simplifies them, replacing them with their single equivalent in plus and minus terms.e.g +++---+ is equivalent to a - and --++-- is equivalent to a +.void
turns the Xsquare into a single variable.void
private void
scan()
Scan the system.void
setExpression
(String expression) void
setScanner
(ArrayList<String> scanner) void
setValid
(boolean valid) private boolean
startsWithDigitOrPoint
(String input) private boolean
startsWithLetter
(String input) private void
The validator of the expression.void
Checks the character set of this parser.void
void
Checks the left and right of a number to see if the appropriate items are the ones there.void
Checks if the variables are properly arranged wrt other tokens.
-
Field Details
-
expression
-
scanner
-
valid
private boolean valid -
vars
-
coefficients
-
-
Constructor Details
-
TartagliaExpressionParser
-
-
Method Details
-
getCoefficients
- Returns:
- the coefficients ArrayList object.
-
freeWhiteSpaces
public void freeWhiteSpaces()removes white space from the ArrayList -
setValid
public void setValid(boolean valid) -
isValid
public boolean isValid() -
setScanner
-
getScanner
-
setExpression
-
getExpression
-
plusAndMinusStringHandler
private void plusAndMinusStringHandler()Handles consecutive strings of plus and minus operators and simplifies them, replacing them with their single equivalent in plus and minus terms.e.g +++---+ is equivalent to a - and --++-- is equivalent to a +. -
indexOfLetter
- Parameters:
input
- The word to search.- Returns:
- the first index of occurrence of a letter, and -1 if no letter of the English alphabet is present.
-
startsWithDigitOrPoint
- Parameters:
input
- The word to search.- Returns:
- true if the input begins with a digit or a point.
-
startsWithLetter
- Parameters:
input
- The word to search.- Returns:
- true if the input begins with a letter.
-
scan
private void scan()Scan the system. -
appendOneToStartOfFreeVariables
public void appendOneToStartOfFreeVariables()When the situation x+2y+z=9; is met, this method will convert it into 1.0x+2y+z=9; -
validateEqualsSymbol
public void validateEqualsSymbol() -
validateChars
public void validateChars()Checks the character set of this parser. -
validateVars
public void validateVars()Checks if the variables are properly arranged wrt other tokens. -
validateNumbers
public void validateNumbers()Checks the left and right of a number to see if the appropriate items are the ones there. It is a syntax error if an invalid item is found there -
validateAll
private void validateAll()The validator of the expression. -
recognizeNegativesAndPositives
public void recognizeNegativesAndPositives() -
recognizeCompoundVariables
public void recognizeCompoundVariables()turns the Xsquare into a single variable. -
getUnknown
- Returns:
- the name of the unknown.
-
doArithmetic
public void doArithmetic()This method initializes the coefficients field with the coefficient of Xsquared at index 0 the coefficient of X at index 1 the coefficient of the constant term at index 2 -
interpretedSystem
- Returns:
- the reduced form of the system in the form Ax³+Bx+C=0;
-
main
-