Class ArithmeticEquation

java.lang.Object
  |
  +--PostfixExpression
        |
        +--ArithmeticEquation

public class ArithmeticEquation
extends PostfixExpression

This class represents an arithmetic equation. For information on the storage method see the constructor and PostfixExpression.setEquation(ExpressionElementStack). For information about how the solution is found, see PostfixExpression.solution().


Fields inherited from class PostfixExpression
expression, TESTING
 
Constructor Summary
ArithmeticEquation(java.lang.String i)
          The calculating for the initialization of this class is fairly complicated.
 
Methods inherited from class PostfixExpression
infixEquation, setEquation, solution, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArithmeticEquation

public ArithmeticEquation(java.lang.String i)
The calculating for the initialization of this class is fairly complicated. It recieves a string representing an infix equation which is then parsed using AdaptedStringTokenizer. The delimiters used in the parse are the tokens from ArithmeticOperatorTable and GenericGroupingSymbolTable. The algorithm used then is this:

After the while loop is through SE now contains all the information that was in the initial string, but all of the information has been identified and pushed into a stack. The only problem is that in the process of pushing it on the stack the order has been reversed, so the ExpressionElementStack.reverse() method is called on SE and SE is sent to the PostfixExpression.setEquation(ExpressionElementStack) of the superclass to be converted and stored in postfix form.

Parameters:
i - string representing an infox arithmetic equation
See Also:
PostfixExpression.setEquation(ExpressionElementStack)