Ejemplo n.º 1
0
        public static Operation createOperiton(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 OperationDev();
                        break;
                    }
                default:
                    {
                        throw new Exception("输入操作符出错");
                    }
            }
            return oper;
        }
 public static Operation CreatOperation(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;
 }