コード例 #1
0
 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));
 }
コード例 #2
0
 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));
     }
 }