00001 package com.graphbuilder.math; 00002 00006 public class DivNode extends OpNode { 00007 00008 public DivNode(Expression leftChild, Expression rightChild) { 00009 super(leftChild, rightChild); 00010 } 00011 00015 public double eval(VarMap v, FuncMap f) { 00016 double a = leftChild.eval(v, f); 00017 double b = rightChild.eval(v, f); 00018 // Laks 2008.05.16: check if the b is zero or not (to avoid an exception) 00019 if(b!=0) 00020 return a / b; 00021 else 00022 return 0; 00023 } 00024 00025 public String getSymbol() { 00026 return "/"; 00027 } 00028 }