org.nfunk.jep.function
Class Add
java.lang.Object
org.nfunk.jep.function.PostfixMathCommand
org.nfunk.jep.function.Add
- All Implemented Interfaces:
- PostfixMathCommandI
- Direct Known Subclasses:
- MAdd
public class Add
- extends PostfixMathCommand
Addition function. Supports any number of parameters although typically
only 2 parameters are used.
- Author:
- nathan
|
Constructor Summary |
Add()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Add
public Add()
run
public void run(Stack stack)
throws ParseException
- Calculates the result of applying the "+" operator to the arguments from
the stack and pushes it back on the stack.
- Specified by:
run in interface PostfixMathCommandI- Overrides:
run in class PostfixMathCommand
- Throws:
ParseException
add
public Object add(Object param1,
Object param2)
throws ParseException
- Adds two numbers together. The parameters can be of type Number,
Complex, or String. If a certain combination of types is not supported,
a ParseException is thrown.
- Parameters:
param1 - The first parameter to be added.param2 - The second parameter to be added.
- Returns:
- The sum of param1 and param2, or concatenation of the two if
they are Strings.
- Throws:
ParseException
add
public Double add(Number d1,
Number d2)
add
public Complex add(Complex c1,
Complex c2)
add
public Complex add(Complex c,
Number d)
Copyright © 2014. All rights reserved.