v1.1 if all algorithm are in one function, it will expand. so each operate type should be separated.

question: if add scientific

operation.cpp:

#include "operation.h"

int OperationAdd(string number1, string number2){

int result= atoi(number1.c_str())+atoi(number2.c_str());

return result;

}

int OperationMinus(string number1, string number2){

int result= atoi(number1.c_str())-atoi(number2.c_str());

return result;

}

int OperationBy(string number1, string number2){

int result= atoi(number1.c_str())*atoi(number2.c_str());

return result;

}

int OperationDivide(string number1, string number2){

int result= atoi(number1.c_str())/atoi(number2.c_str());

return result;

}

int Operation(string number1, string number2, string operateType){

int result=0;

if(operateType=="+"){

result = OperationAdd(number1, number2);

}

else if(operateType=="-"){

result = OperationMinus(number1, number2);

}

else if(operateType=="*"){

result = OperationBy(number1, number2);

}

else if(operateType=="/"){

result = OperationDivide(number1, number2);

}

else{

result =0;

}

return result;

}

to refactor for refactor的更多相关文章

  1. game to refactor for refactor

    first step, only aim to work. it works, but i have not seen the necessaty to use class yet. my quest ...

  2. Delphi Refactor 重构

    delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; ...

  3. [React] Refactor a Class Component with React hooks to a Function

    We have a render prop based class component that allows us to make a GraphQL request with a given qu ...

  4. Xcode的Refactor使用

    最近在看<重构>的书,想到Xcode有一个Refactor的功能,不知道您用的多不多,用这个功能在我们开发过程中,可以提高开发效率. Refactor 右键显示 Refactor 一.Re ...

  5. [Algorithms] Refactor a Linear Search into a Binary Search with JavaScript

    Binary search is an algorithm that accepts a sorted list and returns a search element from the list. ...

  6. [Algorithms] Refactor a Loop in JavaScript to Use Recursion

    Recursion is when a function calls itself. This self calling function handles at least two cases, th ...

  7. [React] Refactor a connected Redux component to use Unstated

    In this lesson, I refactor a simple Counter component connected to Redux to use Unstated instead. I ...

  8. [React] Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3

    The componentWillReceiveProps() method is being deprecated in future version of React (17). Many of ...

  9. [Ramda] Refactor to Point Free Functions with Ramda using compose and converge

    In this lesson we'll take some existing code and refactor it using some functions from the Ramda lib ...

随机推荐

  1. SOA架构大概思路

    1.创建父工程(pom)管理jar包版本 2.创建子工程common工程(jar)管理通用工具类.通用pojo 3.创建服务层工程(聚合工程(pom)) 3.1.创建模块(dao.pojo.inter ...

  2. Django 框架 数据库操作2

    一.ORM的操作方法总结 get(self, *args, **kwargs): # 获取单个对象 def one_get(request): #直接得到一个表对象,也就是表记录 如果得到多个会报错 ...

  3. Python 全栈开发九 日志模块

    日志是一种可以追踪某些软件运行时所发生事件的方法.软件开发人员可以向他们的代码中调用日志记录相关的方法来表明发生了某些事情.一个事件可以用一个可包含可选变量数据的消息来描述.此外,事件也有重要性的概念 ...

  4. python 内置方法expandtabs 把字符串格式化成列表输出

    #!/usr/bin/python3 # -*- coding: utf-8 -*- test = "username\tmail\tage\nzhangsen\tzhangsen@qq.c ...

  5. [Java in NetBeans] Lesson 11. While Loops

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有:(the same use in C/C++) 1. while loop while(i < max){} will keep ...

  6. php 实现php代码的加密解密

    php 代码加密类,大家可以根据自己的需求进行修改,原类如下,是对之前的加密解密类的有一次修改,希望能分享给大家.本次在ubuntu下测试没有问题,与之前的版本的区别在于,这次的版本更加的通用性. & ...

  7. SwingBench 字符模式压测最佳实践

    之前写过<使用SwingBench 对Oracle RAC DB性能 压力测试>,使用的是最基础直观的图形模式,已经可以满足大多数需求. 但是在有些场景下,图形模式可能本身消耗资源过大,尤 ...

  8. gulp打包公共部分

    安装gulp cnpm install gulp -g 输入gulp -v看到版本号说明安装成功了 安装gulp-file-include:npm install gulp-file-include ...

  9. vue中强制刷新的bug处理

    vue是单页面应用,跳转路由也是局部刷新,这里就拿后台管理系统而言,如果你的后台管理系统是左右布局,你不会遇到这样的问题,但是如果你的后台管理系统是上左右布局,你就会遇到这个问题,一级菜单在最上面,二 ...

  10. EL语言表达式 (三)【EL中的算术运算以及判断EL对象是否为空】

    一.EL中的算术运算 EL和其他语言一样,同样也提供了基本的算术运算(加.减.乘.除和取余),如下图. 运算符 功能 示例 结果 + 加 ${19+1} 20 - 减 ${66-30} 36 * 乘 ...