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 ...
随机推荐
- 解决PHP5.6版本“No input file specified”的问题
问题描述:使用TP框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.”原因在于使用的PHP5.6是f ...
- 死锁与递归锁 信号量 event 线程queue
1.死锁现象与递归锁 死锁:是指两个或两个以上的进程或线程在执行过程中,因争抢资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去,此时称系统处于死锁状态或系统产生了死锁,这些永远在互相 ...
- struct模块
struct模块的作用是将数据长度转换成固定长度的内容 一般默认是4个字节 需要注意的是,struct模块是有缺点的,就是struct的int类型或别的类型不是无限制的.当整数大于一定值后,会失败,即 ...
- iot平台在k8s搭建过程
统一在 cd /opt/iot nohup /opt/iopservices.sh >/var/log/helmapi.log & 直接查看pod日志? kubectl logs i ...
- Py中enumerate方法【转载】
转自:http://www.runoob.com/python/python-func-enumerate.html enumerate(sequence, [start=0]) sequence - ...
- windows下使用pyinstaller把python文件打包成exe可执行文件
使用pyinstaller打包有个好处就是所有依赖都打包进去了,可以随意把文件移动到别的电脑上使用 安装 pip install pyinstaller 新建一个demo.py文件 #!/usr/bi ...
- JS发送短信验证码
<div> <input type="tel" id="mobile" name="mobile" placeholder ...
- cocos2d-x C++ 判断当前平台宏定义大全
/**************************************************************************** Copyright (c) 2010-201 ...
- 使用Spark下的corr计算皮尔森相似度Pearson时,报错Can only zip RDDs with same number of elements in each partition....
package com.huawei.bigdata.spark.examples import org.apache.spark.mllib.stat.Statistics import org.a ...
- Oracle与MySQL的比较[内容来自网络]
支持的特性方面的比较: https://www.quora.com/Whats-the-difference-between-Oracle-and-MySQL oracle和mysql在 安全,数据类 ...