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); }
/// <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); }