pstypes
Interface PSArithmeticOperator

All Superinterfaces:
PSObject, PSOperator
All Known Implementing Classes:
PSAbs, PSAdd, PSDiv, PSIdiv, PSMod, PSMul, PSSub

public interface PSArithmeticOperator
extends PSOperator

An object that implements this interface is defined as an arithmetic operator.

This interface defines the group of arithmetic operators.

All arithmetic operators need to make the same basic functions before they execute action().  First,each operator needs to know just how many operands they need.  Second,it should be known the source they have to use as an input of operands(here stack).  Third,a check has to be made whether the number of operands needed, are equal to the number of the input can give.  Four,the type of input from stack has to match the type of data needed by the operator (isValid() method).  Last,if all the checks are fine,then the action,should be executed.

Each specific arithmetic operator should be implemented by one concrete class(ie,one class for each operator) for better organization and management.


Method Summary
 void action(PSStack s)
          Executes the action of the operand as it is implemented by the programmer.
 
Methods inherited from interface pstypes.PSOperator
getOperatorToken, isValid
 

Method Detail

action

public void action(PSStack s)
Executes the action of the operand as it is implemented by the programmer.

The implementor should ensure that some basic checks have been made :

All of the arithmetic operators need to make the same basic functions befor they execute action() : first,each operator needs to know just how many operands they need. 
Second,it should be known the source they have to use as an input of operands(here stack). 
Third,a check has to be made whether the number of operands needed, are equal to the number of the input can give. 
Four,the type of input from the source must be determined and the type of data needed by the operator. 

Precondition : A valid stack is given to method.
Postcondition : The implemented action will be executed.

Parameters:
s - The stack where the operands (here literals) are stored.