// refactoringmotherfucker.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。//#include<iostream>#include<vector>#include<memory>// before refactoring of split loopclassPeople{public:People(double _age,double _salary):age(_age),salary(_salary){}double age;double salary;};classBeforeApplication{public:voiddoWork(){init();printValues();}voidinit(){
peoples_.push_back(std::make_shared<People>(23,8000));
peoples_.push_back(std::make_shared<People>(25,13000));
peoples_.push_back(std::make_shared<People>(30,15000));}voidprintValues(){double averageAge =0;double totalSalary =0;for(int i =0; i < peoples_.size(); i++){
averageAge += peoples_.at(i)->age;
totalSalary += peoples_.at(i)->salary;}
averageAge = averageAge / peoples_.size();
std::cout <<"the average age is: "<< averageAge << std::endl;
std::cout <<"the total salary is: "<< totalSalary << std::endl;}private:
std::vector<std::shared_ptr<People>> peoples_;};// after refactoring of split loopclassAfterApplication{public:voiddoWork(){init();printValues();}voidinit(){
peoples_.push_back(std::make_shared<People>(23,8000));
peoples_.push_back(std::make_shared<People>(25,13000));
peoples_.push_back(std::make_shared<People>(30,15000));}voidprintValues(){
std::cout <<"the average age is: "<<averageAge()<< std::endl;
std::cout <<"the total salary is: "<<totalSalary()<< std::endl;}doubleaverageAge(){double result =0;for(int i =0; i < peoples_.size(); i++){
result += peoples_[i]->age;}return result / peoples_.size();}doubletotalSalary(){double result =0;for(int i =0; i < peoples_.size(); i++){
result += peoples_[i]->salary;}return result;}private:
std::vector<std::shared_ptr<People>> peoples_;};intmain(){// refactoring before
std::shared_ptr<BeforeApplication> before_app = std::make_shared<BeforeApplication>();
before_app->doWork();// refactoring after
std::shared_ptr<AfterApplication> after_app = std::make_shared<AfterApplication>();
after_app->doWork();}
文章目录 Deep learning at base-resolution reveals cis-regulatory motif syntaxproblemBPNet: predicting base-resolution profiles from DNA sequenceInterpreting the predictions of BPNet1 DeepLIFT2 TF-MoDISCO3 motif syntax derived TF cooperativity Experimental …
平台报错缺少 java.lang.RuntimeException:java.lang.ClassNotFoundException: Class org.apache.hadoop.hdfs.DistributedFileSystem not found 实则是缺少jar包 hadoop-hdfs-client-3.1.1.3.1.0.0-78.jar 找到对应的jar放到程序的lib中即可