to refactor for refactor
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的更多相关文章
- 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 ...
- Delphi Refactor 重构
delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; ...
- [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 ...
- Xcode的Refactor使用
最近在看<重构>的书,想到Xcode有一个Refactor的功能,不知道您用的多不多,用这个功能在我们开发过程中,可以提高开发效率. Refactor 右键显示 Refactor 一.Re ...
- [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. ...
- [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 ...
- [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 ...
- [React] Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3
The componentWillReceiveProps() method is being deprecated in future version of React (17). Many of ...
- [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 ...
随机推荐
- Python中__repr__和__str__区别(转)
class Test(object): def __init__(self, value='hello, world!'): self.data = value >>> t = Te ...
- k8s 健康检查
livenessProbe: exec: command: - /bin/sh - '-c' - /opt/app-root/src/check_conf.sh failureThreshold: 3 ...
- Elasticsearch集群管理工具head插件安装
Elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es.或直接下载源码,在本地打开index.html ...
- podofo 一点小分享
PDF 的开源库,大多是Java,或C#的,但C++也有一个很不错的PDF开源库:PoDoFo 我司的PDF签章产品中,我就是用这个PoDoFo库来做的底层 但是国外开源库对中文支持都是或多或少有点问 ...
- JAVA8流操作
* Stream 的三个操作步骤: * 1创建Stream * 2中间操作 * 3终止操作 package airycode_java8.nice6; import airycode_java8.ni ...
- phpcs
phpcs(代码规范) https://juejin.im/post/5b18fdeb6fb9a01e573c3cb3 https://laravel-china.org/docs/psr/psr-2 ...
- Python记录1:基础知识常识
今日内容: 一,Python的数据类型 Python一共有以下几种常见的数据类型:int(整形) float(浮点型) str(字符串) list(列表) tuple元组 dict(字典) ...
- Java基础(basis)-----关键字this和super的作用
1.关键字this 可以用来修饰属性.方法.构造器:this理解为当前对象或当前正在创建的对象 局部变量与成员变量同名,成员变量被屏蔽,用"this.成员变量"的方式访问成员变量 ...
- tr字符串的梗
工作问题总结 声明:应用程序代码为前人所写,仅仅只是维护代码,暂且不论代码风格瑕疵. 结论: 使用tr“包”起来的字符串,可能会被翻译为不同的语言,此时,应用程序在不同语言环境下可能会表现BUG. 1 ...
- Vue 的路由实现 Hash模式 和 History模式
Hash 模式: Hash 模式的工作原理是onhashchange事件,Window对象可以监听这个事件... 可以通过改变路径的哈希值,来实现历史记录的保存,发生变化的hash 都会被浏览器给保存 ...