资源简介
自己手动写的c++版本的重构例子。原书上是Java的。实测可行

代码片段和文件信息
#include“Customer.h“
string Customer::getName()
{
return _name;
}
void Customer::addRental(Rental *r)
{
_rental.push_back(*r);
}
double Customer::getTotalCharge()
{
double result = 0.0;
vector::iterator it;
it = _rental.begin();
while (it != _rental.end())
{
result += it->getCharge();
//迭代器自加
it++;
}
return result;
}
int Customer::getTotalFrequentRenterPoints()
{
int result = 0;
vector::iterator it;
it = _rental.begin();
while (it != _rental.end())
{
//积分+1/+2
result += it->getFrequentRenterPoints();
//迭代器自加
it++;
}
return result;
}
string Customer::statement()
{
string result = “Rental Record for “ + getName() + “\n“;
vector::iterator it;
it = _rental.begin();
while (it != _rental.end())
{
//输出Rental信息
char temp[256];
sprintf_s(temp “\t%s\t%.2f\n“ it->getMovie()->gettitle().c_str() it->getCharge());
result.append(temp);
//迭代器自加
it++;
}
char total[256];
sprintf_s(total “Amout owed is %.2f\n You earned %d frequent renter points“ getTotalCharge() getTotalFrequentRenterPoints());
result.append(total);
return result;
}
string Customer::htmlStatement()
{
string result = “Rental Record for“ + getName() + “
\n“;
vector::iterator it;
it = _rental.begin();
while (it != _rental.end())
{
//输出Rental信息
char temp[256];
sprintf_s(temp “\t%s\t%.2f
\n“ it->getMovie()->gettitle().c_str() it->getCharge());
result.append(temp);
//迭代器自加
it++;
}
char total[256];
sprintf_s(total “Amout owed is %.2f \n You earned %d frequent renter points
“ getTotalCharge() getTotalFrequentRenterPoints());
result.append(total);
return result;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 77312 2017-08-24 17:50 ConsoleApplicationRefactor\.vs\ConsoleApplicationRefactor\v14\.suo
文件 7674 2017-08-24 09:50 ConsoleApplicationRefactor\ConsoleApplicationRefactor\ConsoleApplicationRefactor.vcxproj
文件 1523 2017-08-24 09:50 ConsoleApplicationRefactor\ConsoleApplicationRefactor\ConsoleApplicationRefactor.vcxproj.filters
文件 1813 2017-08-24 14:57 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Customer.cpp
文件 474 2017-08-24 14:50 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Customer.h
文件 3546 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\CL.command.1.tlog
文件 64506 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\CL.read.1.tlog
文件 7144 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\CL.write.1.tlog
文件 237 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\ConsoleApplicationRefactor.lastbuildstate
文件 2412 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\li
文件 4908 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\li
文件 1600 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleA.2BC4EE83.tlog\li
文件 447 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\ConsoleApplicationRefactor.log
文件 274053 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\Customer.obj
文件 263335 2017-08-24 11:22 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\customer.obj.enc
文件 154237 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\Movie.obj
文件 197561 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\MovieRentalTest.obj
文件 34168 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\Rental.obj
文件 494592 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\vc140.idb
文件 462848 2017-08-24 17:43 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Debug\vc140.pdb
文件 1364 2017-08-24 17:39 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Movie.cpp
文件 1144 2017-08-24 17:41 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Movie.h
文件 407 2017-08-24 17:50 ConsoleApplicationRefactor\ConsoleApplicationRefactor\MovieRentalTest.cpp
文件 308 2017-08-24 15:36 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Rental.cpp
文件 357 2017-08-24 14:18 ConsoleApplicationRefactor\ConsoleApplicationRefactor\Rental.h
文件 1360 2017-08-18 08:55 ConsoleApplicationRefactor\ConsoleApplicationRefactor.sln
文件 8564736 2017-08-24 17:50 ConsoleApplicationRefactor\ConsoleApplicationRefactor.VC.db
文件 104960 2017-08-24 17:43 ConsoleApplicationRefactor\Debug\ConsoleApplicationRefactor.exe
文件 543864 2017-08-24 17:43 ConsoleApplicationRefactor\Debug\ConsoleApplicationRefactor.ilk
文件 1650688 2017-08-24 17:43 ConsoleApplicationRefactor\Debug\ConsoleApplicationRefactor.pdb
............此处省略12个文件信息
- 上一篇:人力资源管理系统 课程设计
- 下一篇:Bmob_sdk_v3.6.6
相关资源
- 去掉代码注释的工具java \\ c\\c++、ph
- 算法设计、分析与实现从入门到精通
- 全世界最经典的数据结构教材,Horo
- C++程序设计原理与实践.pdf
- 重构到设计模式的经典案例,超完美
- C++ 程序设计语言:第4部分 标准库原
- android与c++通过socket通信
- socket编程实验报告
- C++Qt5实现雷达及余晖扫描,探测发现
- parasoft c++Test9.0破解
- 白话 C++ 完整版
- PDFlib-6.0.2-Windows库以及java c++开发
- 聊天室系统源码C++ 服务器,PC客户端
- Visual C++6.0助手破解版
- C++ Tutorial for Rational Rhapsody
- C++程序设计语言特别版 Bjarne Stroustr
- C++最强版中国象棋
- Android视频监控系统客户端及服务器端
- Android opencv c++配置工程
- 《C++ for Java Programmers》高清完整英文
- C++ 条码,二维码生成程序Qt 界面
- VISSIM二次开发案例与框架VBA,C++,M
- java JGL标准程序库类似C++的STL
- C++程序设计(谭浩强完整版)
- 算法与数据结构之LeetCode题目详解PD
- java与c++通过socket通信
- 使用JNA的jar包
- Java客户端上传图片文件到c++服务器
- Absolute C++ 6th Edition
- 多个模拟电梯程序Java C C++
评论
共有 条评论