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 ...
随机推荐
- cmd项目目录结构以及配置文件的升级编写
一.项目的目录结构: bin:执行文件夹 config:自定义配置文件 lib:公共的模块或者类文件 src:核心业务逻辑代码 二.配置文件的编写 1)config代码如下 from lib.conf ...
- SAX解析器
1.继承类DefaultHandler package com.SSLSocket.test; import org.xml.sax.Attributes; import org.xml.sax.SA ...
- JS 8-3 prototype属性
动态修改Student.prototype的属性时,会影响已创建或将要创建的实例. 如果将整个Student.prototype赋值为新的对象,对已经创建的实例是不会修改的,会影响后续创建的实例. n ...
- MVC View小技巧
1.在View中添加命名空间引用 1)直接在.cshtml文件中添加 @using MvcMusicStore.Models 2)在Views文件夹的web.config文件中添加,对整个Views文 ...
- JMeter TCP性能测试
jmeter是一款纯java的性能测试工具,跨平台运行方便.提供图形化界面设置.简单易用. 在性能测试方法论中,很典型的方法就是二八原则,量化业务需求. 二八原则:指80%的业务量在20%的时 ...
- 胸片和CT断层图像是怎么来的?
本文作者系医科大学青年教师,关注公众号"计算机视觉life"菜单栏回复"医学" 进群交流 如何得到CT断层图像? 相信小伙伴体检的时候都拍过胸片,假如哪个不幸的 ...
- HDU 2254 奥运(矩阵+二分等比求和)
奥运 [题目链接]奥运 [题目类型]矩阵+二分等比求和 &题解: 首先离散化城市,之后就是矩阵快速幂了,但让求的是A^(t1)+A^(t1+1)+...+A^(t2),我先想的是打表,但时间真 ...
- unity之让obj旋转自转等操作
1.让cube沿着矩形四个点运动 using System.Collections; using System.Collections.Generic; using UnityEngine; publ ...
- tp连贯操作
链接数据库 首先写配置文件 复制concentration.php中的 /* 数据库设置 */ 'DB_TYPE' => '', // 数据库类型 'DB_HOST' => '', // ...
- protobuf编译.proto文档
1:在同一目录下按键盘shift+鼠标右键-->点击-->在此处打开命令窗口,打开后如下图所示 2.该目录下有person.proto文档,可以自己编写,如下 syntax = " ...