/// <summary> /// Performs the entered operation with the right and left child /// </summary> /// <returns></returns> public int Count() { switch (data) { case '+': { return(LeftChild.Count() + RightChild.Count()); } case '-': { return(LeftChild.Count() - RightChild.Count()); } case '*': { return(LeftChild.Count() * RightChild.Count()); } case '/': { if (RightChild.Count() == 0) { throw new DivideByZeroException(); } return(LeftChild.Count() / RightChild.Count()); } } return(-1); }
public override double Count() => Math.Abs(RightChild.Count()) <= 1e-6 ? throw new DivideByZeroException() : LeftChild.Count() / RightChild.Count();
public override double Count() => LeftChild.Count() + RightChild.Count();