package org.nfunk.jep.function;

import java.util.Stack;
import org.nfunk.jep.ParseException;
import org.nfunk.jep.type.Complex;

public class Polar extends PostfixMathCommand {
  public void run(Stack paramStack) throws ParseException {
    checkStack(paramStack);
    Number number1 = (Number)paramStack.pop();
    Number number2 = (Number)paramStack.pop();
    if (number2 instanceof Number && number1 instanceof Number) {
      paramStack.push(Complex.polarValueOf(number2, number1));
    } else {
      throw new ParseException("Complex: Invalid parameter types " + number2.getClass().getName() + " " + number2.getClass().getName());
    } 
  }
}
