game to refactor for refactor

main.cpp:

#include <iostream>

#include <iostream>

#include "operation.h"

using namespace std;

int main(int argc, const char * argv[]) {

// insert code here...

std::cout << "Hello!\n";

string numberA,numberB,operateType;

std::cout<<"please input numberA:\n";

std::cin >>numberA;

std::cout<<"operate type";

std::cin>>operateType;

std::cout<<"please input numberB:\n";

std::cin>>numberB;

std::cout<<"output:"<<Operation(numberA,numberB,operateType);

//why use class to

return 0;

}

operation.h:

#include <iostream>

using namespace std;

int Operation(string number1, string number2, string operateType);

operation.cpp:

#include "operation.h"

int Operation(string number1, string number2, string operateType){

int result=0;

if(operateType=="+"){

result = atoi(number1.c_str())+atoi(number2.c_str());

}

else if(operateType=="-"){

result = atoi(number1.c_str())-atoi(number2.c_str());

}

else if(operateType=="*"){

result = atoi(number1.c_str())*atoi(number2.c_str());

}

else if(operateType=="/"){

result = atoi(number1.c_str())/atoi(number2.c_str());

}

else{

result =0;

}

return result;

}

时间: 2024-10-10 10:44:00

game to refactor for refactor的相关文章

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_s

Xcode的Refactor使用

最近在看<重构>的书,想到Xcode有一个Refactor的功能,不知道您用的多不多,用这个功能在我们开发过程中,可以提高开发效率. Refactor 右键显示 Refactor 一.Rename 重命名符号,修改属性或方法的名字.当然有可能您用的是全局Replace这个方法,但是这个无法替换Class的文件名.演示下将TestViewController的.h .m .xib及用到的地方修改为有意义的命HomeViewController. 1.在TestViewController上右键点

Own (and Refactor) the Build

Own (and Refactor) the Build Steve Berczuk iT iS NOT UNCOMMON for teams that are otherwise highly disciplined about coding practices to neglect build scripts, either out of a belief that they are merely an unimportant detail or from a fear that they

Before You Refactor

Before You Refactor Rajith Attapattu AT SOME POiNT, every programmer will need to refactor existing code. But before you do so, please think about the following, as this could save you and others a great deal of time (and pain): ? The best approach f

Delphi Refactor 重构

delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; begin a:=CameraComponent1.CaptureSetting.Width.ToString; Memo1.Lines.Add( a); end; 不仅可以重构成 过程 还可以重构函数参数,真强大! procedure TCameraComponentForm.btnRefres

[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. It provides a dramatic performance boost over searching linearly through a list for an element. Let’s play around number of iterations required for e

[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 query string and variables and uses a GitHub graphql client that is in React context to make the request. Let's refactor this to a function component th

refactor window_x64微信小程序环境搭建

所需文件地址如下: https://github.com/zsyzsy/weixinxiaochengxun 1.下载微信开发工具0.7.0_x64 安装完成后,打开程序,进行微信扫码登录 2.下载微信开发工具0.9.092300_x64 注意:版本一定要是0.9.092300,小于这个版本,打开程序会白屏 安装(覆盖0.7.0的版本),不要打开程序 3.下载破解文件 进行如下文件的替换 \package.nw\app\dist\components\create\createstep.js \

[Express] Level 5: Route Instance -- refactor the code

Route Instance Let's rewrite our cities routes using a Route Instance. Create a new Route Instance for the '/cities' URL path and assign it to thecitiesRoute variable. var citiesRoute = app.route('/cities'); Move the code from our previous app.get()