public override IFunction Simplify() { if (ToRight.GetType() == typeof(Numbers)) { if (ToRight.ToInfix() == "0") { throw new Exception("Can not divide by zero!"); } } if (Toleft.GetType() == typeof(Numbers)) { if (Toleft.ToInfix() == "0") { return(new Numbers(0)); } } return(new DevisionFunction(Toleft, ToRight)); }
public override IFunction Simplify() { if (Toleft.GetType() == typeof(Numbers)) { if (Toleft.ToInfix() == "0") { return(new Numbers(0)); } } if (ToRight.GetType() == typeof(Numbers)) { if (ToRight.ToInfix() == "0") { return(new Numbers(0)); } return(new Multiplication(Toleft, ToRight)); } else { return(new Multiplication(Toleft, ToRight)); } }
public override string ToInfix() { string toprefixvalue = Toleft.ToInfix() + ToRight.ToInfix(); return(toprefixvalue); }