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的更多相关文章

  1. 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 ...

  2. Delphi Refactor 重构

    delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; ...

  3. [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 ...

  4. Xcode的Refactor使用

    最近在看<重构>的书,想到Xcode有一个Refactor的功能,不知道您用的多不多,用这个功能在我们开发过程中,可以提高开发效率. Refactor 右键显示 Refactor 一.Re ...

  5. [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. ...

  6. [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 ...

  7. [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 ...

  8. [React] Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3

    The componentWillReceiveProps() method is being deprecated in future version of React (17). Many of ...

  9. [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 ...

随机推荐

  1. 入门 Webpack,看这篇就够了

    转:https://segmentfault.com/a/1190000006178770 2018年8月25日更新,目前 webpack 已经更新值 4.17.1 ,本文所用到的各种库或多或少有些过 ...

  2. Redis cluster集群:原理及搭建

    Redis cluster集群:原理及搭建 2018年03月19日 16:00:55 阅读数:6120 1.为什么使用redis? redis是一种典型的no-sql 即非关系数据库 像python的 ...

  3. 部分还款-还款试算接口与还款接口-python

    一.还款试算.还款接口, 1.只传入参数loan_Code 2.还款接口参数化以下: "loanCode": loanCode1,"orderId": orde ...

  4. [Java in NetBeans] Lesson 01. Java Programming Basics

    这个课程的参考视频在youtube. 主要学到的知识点有: Create new project, choose Java Application. one .jar file/ package(.j ...

  5. Macbook pro开启允许任何源

    sudo spctl --master-disable

  6. ubuntu16.4菜单栏不见,终端不见解决方法

    1.ctrl+alt+f1进入命令行 2. sudo apt-get install gnome-terminal 3.sudo apt-get install unity 4.setsid unit ...

  7. React对比Vue(02 绑定属性,图片引入,数组循环等对比)

    import React, { Component } from 'react'; import girl from '../assets/images/1.jpg' //这个是全局的不要this.s ...

  8. ASP.NET MVC4中加入Log4Net日志记录功能

    前言 在之前的.NET中,微软还没有提供过像样的日志框架,目前能用的一些框架比如Log4Net.NLog.CommonLogging等,虽然多多少少使用起来有点费劲,但这里还是简单分享一下Log4Ne ...

  9. linux打包压缩与搜索命令

    1.tar命令 tar命令用于对文件进行打包压缩或解压,格式为“tar [选项] [文件]”.  tar命令的参数及其作用 参数 作用 -c 创建压缩文件 -x 解开压缩文件 -t 查看压缩包内有哪些 ...

  10. GCD(莫比乌斯+去重)

    题目链接 莫比乌斯反演模板题, 去重即可: 我们可以发现只有在区间重叠部分才会有重复且为cal(e, e, k)/2;(e表示b, d中较小的一个): #include<cstdio> # ...