コード例 #1
0
        public static Operation CreateOperate(string operate)
        {
            Operation operation = null;

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

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

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

            case "/": {
                operation = new OperationDiv();
                break;
            }
            }
            return(operation);
        }
コード例 #2
0
        public static Operation CreateOperate(string operate)
        {
            //根据传入的参数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);
        }
コード例 #3
0
        public static Operation createOperation(string operate)
        {
            Operation operation = null;

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

            case "-":
                operation = new OperationMinus();
                break;

            case "*":
                operation = new OperationMulti();
                break;

            case "/":
                operation = new OperationDivision();
                break;

            default:
                throw new Exception("錯誤:請輸入加減乘除!!");
            }

            return(operation);
        }
コード例 #4
0
        public static Operation CreatOperate(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("input error");
            }

            return(oper);
        }
コード例 #5
0
        public static Operation CreateOperation(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:
                oper = null;
                break;
            }
            return(oper);
        }
コード例 #6
0
        public static Operation CreateOperation(string strOperation)
        {
            Operation operation = null;

            switch (strOperation)
            {
            case "+":
                operation = new OperationAdd();
                break;
            }
            return(operation);
        }
コード例 #7
0
        public static Operation CreateOperate(string operate)
        {
            Operation oper = null;

            switch (operate)
            {
            case "+":
                oper = new OperationAdd();
                break;
            }
            return(oper);
        }
コード例 #8
0
        public static Operation CreateFactory(string operation)
        {
            Operation oper = null;

            switch (operation)
            {
            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);
        }
コード例 #9
0
 public static Operation CreateOperation(string op)
 {
     Operation oper = null;
     switch (op)
     {
         case "+":
             oper = new OperationAdd();
             break;
         case "-":
             oper = new OperationSub();
             break;
         case "*":
             oper = new OperationMul();
             break;
         case "/":
             oper = new OperationDiv();
             break;
     }
     return oper;
 }
コード例 #10
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;

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

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

            case "+/-":
                oper = new OperationReverse();
                break;
            }
            return(oper);
        }
コード例 #11
0
        public static Operation CreateOperation(String operation)
        {
            Operation o = null;

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

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

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

            case "/":
                o = new OperationDiv();
                break;
            }
            return(o);
        }
コード例 #12
0
ファイル: Operation.cs プロジェクト: ElvinChan/DesignPattern
 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;
 }