EDU.ksu.cis.calculator.javamodel
Class Add
java.lang.Object
|
+--EDU.ksu.cis.calculator.javamodel.Add
- All Implemented Interfaces:
- EncodedOperation, Operation
- public class Add
- extends Object
- implements EncodedOperation
The add operation.
- Author:
- Rod Howell
(howell@cis.ksu.edu)
Constructor Summary |
Add()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Add
public Add()
numOperands
public int numOperands()
- Returns 2.
- Specified by:
numOperands
in interface Operation
doOperation
public Object doOperation(Object[] operands)
throws ArrayIndexOutOfBoundsException,
ClassCastException
- Returns the result of adding the given operands.
- Specified by:
doOperation
in interface EncodedOperation
- Parameters:
operands
- The operands for the operation. The length of
this array should match the value returned by
Operation.numOperands()
.
- Returns:
- The result of the operation.
- Throws:
ArrayIndexOutOfBoundsException
- If operands is not of
length at least 2.
ClassCastException
- If the elements of operands are not
both BigIntegers.