1 8 package org.lsmp.djep.groupJep.function; 9 import org.nfunk.jep.function.*; 10 import org.lsmp.djep.groupJep.*; 11 import java.util.*; 12 import org.nfunk.jep.*; 13 17 public class GUMinus extends PostfixMathCommand { 18 private GroupI group; 19 22 private GUMinus() { } 23 public GUMinus(GroupI group) 24 { 25 numberOfParameters = 1; 26 this.group = group; 27 } 28 29 33 public void run(Stack stack) throws ParseException { 34 checkStack(stack); 36 Object sum = stack.pop(); 37 stack.push(uminus(sum)); 38 return; 39 } 40 41 public Object uminus(Object param1) throws ParseException { 42 if (param1 instanceof Number ) { 43 return group.getInverse((Number )param1); 44 } 45 throw new ParseException("Invalid parameter type"); 46 } 47 } 48 | Popular Tags |