EDU.ksu.cis.calculator.defaultmodel
Class TwoToPower
java.lang.Object
|
+--EDU.ksu.cis.calculator.defaultmodel.TwoToPower
- All Implemented Interfaces:
- EncodedOperation, Operation
- public class TwoToPower
- extends Object
- implements EncodedOperation
The operation of raising 2 to an arbitrary power.
- Author:
- Rod Howell
(howell@cis.ksu.edu)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TwoToPower
public TwoToPower()
numOperands
public int numOperands()
- Returns 1.
- Specified by:
numOperands
in interface Operation
doOperation
public Object doOperation(Object[] operands)
throws ArrayIndexOutOfBoundsException,
ClassCastException,
ArithmeticException
- Returns the result of raising 2 to the power of operands[0].
- 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 1.
ClassCastException
- If operands[0] is not
a LargeInteger.
ArithmeticException
- If operands[0] is negative.