资源简介
自己手动写的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
相关资源
- 使用JNA的jar包
- Java客户端上传图片文件到c++服务器
- Absolute C++ 6th Edition
- 多个模拟电梯程序Java C C++
- C++与android通过socket通信
- C/C++服务器与Java客户端进行socket通信
- 数据结构C++版.emmx
- 小游戏 21点 网络版 java C++
- 蓝桥杯练习系统试题及答案 JAVA版真题
- A Tour of C++ 2nd Edition (2018.7出版EPU
- Android调用C++实现共享内存
- javaRSA加密C++RSA解密
- C++ 标准程序库.pdf
- Effective C++ 中文版
- 广东工业大学网络课程设计ping程序设
- 基于linux C/C++和android的酒店终端管理
- vtk-5.8.0.tar
- The C++ Programming Language Special Edition 中
- 剑指offer完整版PDF带目录源码C++和Ja
- starUML5.0 建模工具 支持C C++ JAVA逆向工
- 遗传算法多份源代码matalabjava,c++都有
- 词法分析器实现java和c++
- android移动端和PC端互作客户和服务器
- 画程(版本6.0.0.127)setup个人版
- Android FFMPEG 的so库
- c++实现向web服务器上传文件
- 深度探索c++对象模型insideinside the c+
- zw_AndroidC++高级编程使用NDKPDF电子书带
- C++国外3D多人坦克游戏源码
- A tour of C++ 2nd
评论
共有 条评论