pascalinterpreter.operators
Class Arithmetic

java.lang.Object
  extended bypascalinterpreter.Operator
      extended bypascalinterpreter.BinaryOperator
          extended bypascalinterpreter.operators.Arithmetic
Direct Known Subclasses:
Add, Divide, Multiple, Subtract

public abstract class Arithmetic
extends BinaryOperator


Field Summary
 
Fields inherited from class pascalinterpreter.Operator
OP_REG_VAR_NAME
 
Constructor Summary
Arithmetic()
           
 
Method Summary
protected abstract  double compute(double opL, double opR)
          Metoda oblicza wartosc wyrazenia.
 void execute(Variable operandL, Variable operandR)
           
private  void setRegistry(DataType type, double value)
          Metoda konwertuje wartość do wybranego typu i zapisuje do rejestru programu.
 
Methods inherited from class pascalinterpreter.BinaryOperator
execInitialize, isPossible, makeConversion, parseDouble
 
Methods inherited from class pascalinterpreter.Operator
getRegistry, setRegistry, setRegistry, setRegistry, setRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Arithmetic

public Arithmetic()
Method Detail

execute

public void execute(Variable operandL,
                    Variable operandR)
             throws InternalException,
                    RuntimeException
Specified by:
execute in class BinaryOperator
Throws:
InternalException
RuntimeException

setRegistry

private void setRegistry(DataType type,
                         double value)
                  throws InternalException
Metoda konwertuje wartość do wybranego typu i zapisuje do rejestru programu.

Parameters:
type - - typ, jakiego ma być zmienna
value - - wartość zmiennej
Throws:
InternalException - - Wyjątek generowany, jeżeli operacja nie może zostać wykonana.

compute

protected abstract double compute(double opL,
                                  double opR)
Metoda oblicza wartosc wyrazenia. Wszystkie operacje, z wyjatkiem dodawania wykonywane sa na zmiennych typu double.

Parameters:
opL - - lewy operand
opR - - prawy operand
Returns:
Wartość wyrażenia, w postaci liczby double.