1 8 package org.lsmp.djep.groupJep.function; 9 import org.nfunk.jep.function.*; 10 import org.lsmp.djep.groupJep.*; 11 12 import java.util.*; 13 import org.nfunk.jep.*; 14 18 public class GSubtract extends PostfixMathCommand { 19 private GroupI group; 20 23 private GSubtract() { } 24 public GSubtract(GroupI group) 25 { 26 numberOfParameters = 2; 27 this.group = group; 28 } 29 30 34 public void run(Stack stack) throws ParseException { 35 checkStack(stack); Object sum = stack.pop(); 37 Object param; 38 param = stack.pop(); 39 sum = sub(param, sum); 40 stack.push(sum); 41 return; 42 } 43 44 public Object sub(Object param1, Object param2) throws ParseException { 45 if (param1 instanceof Number ) { 46 if (param2 instanceof Number ) { 47 return group.sub((Number )param1, (Number )param2); 48 } 49 } 50 51 throw new ParseException("Invalid parameter type"); 52 } 53 } 54 | Popular Tags |