IfFunction.java
Go to the documentation of this file.00001 package com.graphbuilder.math.func;
00002
00003 public class IfFunction implements Function {
00004
00005 public double of(double[] param, int numParam) {
00006
00007 final boolean condition = (0 == param[0]);
00008 double result = 0.0;
00009
00010 if (condition) {
00011 result = param[1];
00012 } else if (numParam == 3) {
00013 result = param[2];
00014 }
00015 return result;
00016 }
00017
00018 public boolean acceptNumParam(int numParam) {
00019 return (numParam==2 || numParam==3);
00020 }
00021
00022 public String toString() {
00023 return "if(condition,val_if_true,val_if_false)";
00024 }
00025
00026 }