Пример #1
0
        public static Operation CreateOperate(string operate)
        {
            Operation oper = null;

            switch (operate)
            {
            case "+":
            {
                oper = new OperationAdd();
                break;
            }

            case "-":
            {
                oper = new OperationSub();
                break;
            }

            case "*":
            {
                oper = new OperationMul();
                break;
            }

            case "/":
            {
                oper = new OperationDiv();
                break;
            }
            }

            return(oper);
        }
        public static Operation createOperate(string operate)
        {
            Operation oper = null;

            switch (operate)
            {
            case "+":
            {
                oper = new OperationAdd();
                break;
            }

            case "-":
            {
                oper = new OperationSub();
                break;
            }

            case "*":
            {
                oper = new OperationMul();
                break;
            }

            case "/":
            {
                oper = new OperationDiv();
                break;
            }

            case "sqr":
            {
                oper = new OperationSqr();
                break;
            }

            case "sqrt":
            {
                oper = new OperationSqrt();
                break;
            }

            case "+/-":
            {
                oper = new OperationReverse();
                break;
            }
            }

            return(oper);
        }
Пример #3
0
        public static Operation CreateOperation(string sign)
        {
            Operation returnObj = null;

            switch (sign)
            {
            case "+": returnObj = new OperationAdd(); break;

            case "-": returnObj = new OperationSub(); break;

            case "*": returnObj = new OperationMul(); break;

            case "/": returnObj = new OperationDiv(); break;

            case "%": returnObj = new OperationMod(); break;
            }

            return(returnObj);
        }
Пример #4
0
        public static Operation createOperate(string operate)
        {
            Operation oper = null;

            switch (operate)
            {
            case "+":
            {
                oper = new OperationAdd();
                break;
            }

            case "-":
            {
                oper = new OperationSub();
                break;
            }

            case "*":
            {
                oper = new OperationMul();
                break;
            }

            case "/":
            {
                oper = new OperationDiv();
                break;
            }

            default:
            {
                throw new Exception("操作数错误\n");
            }
            }

            return(oper);
        }
 public static Operation createOperate(string operate)
 {
     Operation oper = null;
     switch (operate)
     {
         case "+":
             {
                 oper = new OperationAdd();
                 break;
             }
         case "-":
             {
                 oper = new OperationSub();
                 break;
             }
         case "*":
             {
                 oper = new OperationMul();
                 break;
             }
         case "/":
             {
                 oper = new OperationDiv();
                 break;
             }
         case "sqr":
             {
                 oper = new OperationSqr();
                 break;
             }
         case "sqrt":
             {
                 oper = new OperationSqrt();
                 break;
             }
         case "+/-":
             {
                 oper = new OperationReverse();
                 break;
             }
     }
     return oper;
 }