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 ...
随机推荐
- api-gateway-engine知识点(1)
1 密钥绑定时,通过Channel 实现监控 后台发送数据 : redisTemplate.convertAndSend(RedisMessageChannel.API_GATEWA ...
- Java知识点ArrayList
ArrayList List<ApiSvcVersion> apiSvcVersionList = apiSvcVersionDao.getListByClientId(map1); // ...
- (转)Marathon健康检查
健康检查是需要每个应用运行监控检查任务的. 1.默认的健康检查是延迟才能让mesos知道任务的状态是否健康. 2.marathon提供一个任务资源的健康成员访问的REST API接口. 如果HTTP的 ...
- Django 框架 数据库操作
数据库与ORM 1 django默认支持sqlite,mysql, oracle,postgresql数据库. <1> sqlite django默认使用sqlite的数据库,默认 ...
- Mac上安装PHP、Apache、MySQL
Mac自带php5.6版本,要升级到php7.3 步骤如下 1,brew 安装php ,如果没有安装,访问https://brew.sh/index_zh-cn安装在终端输入以下内容,不用指定安装ph ...
- [LeetCode] questions conclusion_ Binary Search
Binary Search T(n) = T(n/2) + O(1) => T(n) = O(lg n) proof: 如果能用iterable , 就用while loop, 可以防 ...
- js 图片区域可点击,适配移动端,图片大小随意改变
实现图片区域可点击,实际上使用map是可以的,但是适配效果并不好,图片只能是固定大小的值,而且点都被写死了. 在这里,我使用的js基于canvas写的一个小工具.可以圈出你需要点击的部分,然后生成一串 ...
- CentOS6.5安装sqoop2
1.下载软件:http://archive.cloudera.com/cdh5/cdh/5/ 2.解压:tar -zxvf mysofts/sqoop2-1.99.5-cdh5.6.0.tar.gz ...
- 隐藏apache服务器信息
安装完apache一般第一时间都是关闭apache的版本信息,黑客会通过apache暴露出来的信息针对性的入侵,为了服务器的安全这些信息一定要及时关闭. 1.隐藏PHP版本 修改php.ini exp ...
- vue中把table导出表格excel
1.首先下载2个js,我的百度网盘有 2.安装依赖 npm install -S file-saver xlsx(这里其实安装了2个依赖) npm install -D script-loader 3 ...