Ejemplo n.º 1
0
        public static Operation CreateOperate(string operate)
        {
            Operation oper = null;

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

            case "-":
                oper = new OperationMul();
                break;

            case "*":
                oper = new OperationMub();
                break;

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

            default:
                break;
            }
            return(oper);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 返回实例对象
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static Operation CreateOperation(string operation)
        {
            Operation operationObj = null;

            switch (operation)
            {
            case  "+":
                operationObj = new OperationAdd();
                break;

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

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

            case  "/":
                operationObj = new OperationDiv();
                break;
            }
            return(operationObj);
        }