com.jp.comp.calculator
Interface CalculatorOperation


public interface CalculatorOperation

Performs calculator's operation. All calculator's operations must implement this interface

See Also:
Calculator

Method Summary
 boolean isInvokedImmediately()
          Returns true if the operation should be executed immediately and not waiting for the second operand.
 boolean isRepeatable()
          Returns true if the operation is repeatable.
 boolean isShowResult()
          Returns true if the operation's result should be shown on the CalculatorPanel display
 boolean isStandalone()
          Returns true if the operation is standalone.
 java.math.BigDecimal performOperation(Calculator aCalculator, java.math.BigDecimal aFirstOperand, java.math.BigDecimal aSecondOperand)
          Performs calculator's operation
 

Method Detail

performOperation

public java.math.BigDecimal performOperation(Calculator aCalculator,
                                             java.math.BigDecimal aFirstOperand,
                                             java.math.BigDecimal aSecondOperand)
                                      throws CalculatorException
Performs calculator's operation

Parameters:
aCalculator - Calculator instance
aFirstOperand - first operand. Comes from the calculator's state map
aSecondOperand - second operand. Comes from the CalculatorPanel display
Returns:
result of the operation
Throws:
CalculatorException

isInvokedImmediately

public boolean isInvokedImmediately()
Returns true if the operation should be executed immediately and not waiting for the second operand. For example SQRT, 1/x

Returns:
true if the operation should be executed immediately

isStandalone

public boolean isStandalone()
Returns true if the operation is standalone. Standalone operations perform computations and calculator's state map changes itself returning the result of its computation. Nonstandalone operations just perform computations on two operandsands (like subtraction and multiplication), return the result of its computation and do nothing with calculator's state map. Calculator decides itself can this operation be performed immediately or put to the state map to be performed later when second operand is received

Returns:
true if the operation is standalone.

isShowResult

public boolean isShowResult()
Returns true if the operation's result should be shown on the CalculatorPanel display

Returns:
true if the operation's result should be shown

isRepeatable

public boolean isRepeatable()
Returns true if the operation is repeatable. Repeatable means that the operation can be put in the calculator state map and repeat again with a new fist operand by clcking equal button. For example 2+3=5. Next click on equal will return 8 (5+3), next 11 (8+3) and so on

Returns:
true if the operation is repeatable