1 9 10 package org.nfunk.jep.function; 11 12 import java.util.*; 13 import org.nfunk.jep.*; 14 import org.nfunk.jep.type.*; 15 21 public class ComplexPFMC extends PostfixMathCommand 22 { 23 public ComplexPFMC() 24 { 25 numberOfParameters = 2; 26 } 27 28 public void run(Stack inStack) 29 throws ParseException 30 { 31 checkStack(inStack); Object param2 = inStack.pop(); 33 Object param1 = inStack.pop(); 34 35 if ((param1 instanceof Number ) && (param2 instanceof Number )) 36 { 37 double real = ((Number )param1).doubleValue(); 38 double imag = ((Number )param2).doubleValue(); 39 40 inStack.push(new Complex(real,imag)); 41 } 42 else 43 { 44 throw new ParseException("Complex: Invalid parameter types "+param1.getClass().getName()+" "+param1.getClass().getName()); 45 } 46 return; 47 } 48 } 49 | Popular Tags |