calc
Class BaseCalc

java.lang.Object
  |
  +--calc.BaseCalc
Direct Known Subclasses:
AddCalc, CosCalc, DivCalc, ExpCalc, ImCalc, MultiplyCalc, NumeralCalc, PowerCalc, RealCalc, SinCalc, SubtractCalc, VariableCalc, ZetaCalc

public abstract class BaseCalc
extends java.lang.Object

This class is the base for all kind of calculations. It's subclasses represent the nodes in the Operational Tree constructed by ExprParser


Field Summary
protected  boolean calculated
           
protected  BaseCalc[] children
           
protected  Complex result
           
 
Constructor Summary
BaseCalc()
           
 
Method Summary
 void calculate()
          Wrapper for doCalculate.
 void clear()
          remove the calculated-flag
protected abstract  void doCalculate()
          implemented by subclasses, does the real calculation by recursively calling it's children
abstract  int getArgsNr()
          overridden by inheriting class, needed for consistency-checks
abstract  java.lang.String getArithmeticSymbol()
          must be implemented for debugging purposes: returns "+" for AddCalc, etc.
 BaseCalc[] getChildren()
          returns an array with the child-nodes
 void insertChildren(BaseCalc[] children)
          connects the Object to another BaseCalc and uses it's output as input
static void main(java.lang.String[] args)
          for testing purposes
 Complex result()
          return the result calculated by calculate()
 java.lang.String toString()
          returns a string representing the arithmetic operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

result

protected Complex result

children

protected BaseCalc[] children

calculated

protected boolean calculated
Constructor Detail

BaseCalc

public BaseCalc()
Method Detail

getArgsNr

public abstract int getArgsNr()
overridden by inheriting class, needed for consistency-checks

insertChildren

public void insertChildren(BaseCalc[] children)
                    throws calc.IllegalArgException
connects the Object to another BaseCalc and uses it's output as input

getChildren

public BaseCalc[] getChildren()
returns an array with the child-nodes

calculate

public void calculate()
Wrapper for doCalculate. Keeps track of the state

doCalculate

protected abstract void doCalculate()
implemented by subclasses, does the real calculation by recursively calling it's children

result

public Complex result()
return the result calculated by calculate()

clear

public void clear()
remove the calculated-flag

toString

public java.lang.String toString()
returns a string representing the arithmetic operation
Overrides:
toString in class java.lang.Object

getArithmeticSymbol

public abstract java.lang.String getArithmeticSymbol()
must be implemented for debugging purposes: returns "+" for AddCalc, etc.

main

public static void main(java.lang.String[] args)
for testing purposes