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 全栈开发十 socket网络编程
一.客户端(client)服务端(sever)架构 在计算机中有很多常见的C/S架构,例如我们的浏览器是客户端.而百度网站和其他的网站就是服务端:视频软件是客户端,提供视频的腾讯.优酷.爱奇艺就是服务 ...
- left join不同写法导致数据差异
select m.*, p.specification, p.sales_price, p.promotion_price from product_detail p left join PRODUC ...
- 大牛推荐的10本学习 Python 的好书
Python:蛇亚目蟒科,主要包括分布于非洲及亚洲的无毒蟒蛇. Python:Richard Clabaugh拍摄的恐怖电影,2000年发行. Python:澳大利亚汽车公司. Python:英国偶发 ...
- np.percentile()
np.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=Fal ...
- centos make error: fatal error: curses.h: No such file or directory
yum install ncurses.x86_64 yum install ncurses-devel.x86_64 yum install ncurses-libs.x86_64 yum inst ...
- iOS 第三方框架-MJExtension
1.数组转换成模型数组 // 将 "微博字典"数组 转为 "微博模型"数组 NSArray *newStatuses = [HWStatus objectArr ...
- sqli-labs(十七)
第五十四关: 这关大概意思就是尝试次数不能多于十次,必须十次之类查询处特点的key. 第一次:输入单引号报错 第二次:输入双引号不报错 说明后台是单引号进行的拼凑 第三步:这里应该是判断列,用orde ...
- [ English ] Ping sb.
What does "Ping Me" mean? Recently, when I asked a colleague to ping me, he responded wi ...
- Beta冲刺阶段5.0
1. 提供当天站立式会议照片一张 2. 每个人的工作 (有work item 的ID) 成员 昨天已完成的工作 今天计划完成的工作 工作中遇到的困难 具体贡献 郑晓丽 首页活动详情界面的美化 实现首页 ...
- 五 js对象简介
对象简介 js中没有"类"的概念,只有对象. A:对象声明方式有三种 ------------1.调用Object函数创建对象: var person = new Object; ...