ImageVerifierCode 换一换
格式:DOCX , 页数:29 ,大小:74.82KB ,
资源ID:8311868      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8311868.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(面向对象实验报告.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

面向对象实验报告.docx

1、面向对象实验报告面向对象程序设计 学号:10410901048 10410901044 姓名: 葛建涛 王登普 班级: 10级计科(1)班 时间: 2011年10月16日音像店管理系统程序设计实验项目名称:音像店管理系统课程名称:面向对象程序设计面向专业:计算机科学与技术 实验目的:利用面向对象程序设计思想编写一个程序使得音像店可以正常工程。实验目标与要求:程序应该执行以下操作:1、 出租影碟。2、 返还影碟。3、 创建音像商店拥有的影碟清单。4、 打印商店所有硬碟的清单。5、 显示某张特定影碟的清单。6、 检查某张影碟是否在商店中。7、 维护顾客的数据库。8、 打印每位顾客所租的所有影碟清单

2、。实验环境要求:VC+6.0实验仪器设备:一台计算机实验语言:C+实验内容:程序需求表明音像店有2个主要组成部分:影碟和顾客。程序在描述这2个组成部分的同时还需要生成以下2个列表:1. 商店所有影碟的列表。2. 商店所有顾客的列表。在这里分2个部分分析,第1部分设计、实现和测试影碟部分,第2部分设计和实现顾客部分并加入到第1部分开发的影碟部分。1、 影碟影碟对象描述影碟相关的通常属性,如下: string videoTitle; /片名 string movieStar1; /明星1 string movieStar2; /明星2 string movieProducer; /制片人 stri

3、ng movieDirector; /导演 string movieProductionCo; /制片公司 int copiesInStock; /列表中拷贝的数量 int VideoID; /影碟的编号音像店系统管理程序中有关影碟的类:类基类说明VideoType无一张影碟VideoListTypelist影碟列表,VideoType对象的列表,继承于STL标准列表容器VideType类:函数模块功能成员说明string videoTitle片名string movieStar1明星1string movieStar2明星2string movieProducer制片人string movi

4、eDirector导演string movieProductionCo制片公司int copiesInStock列表中拷贝的数量int VideoID影碟的编号void setVideoInfo(string title, string star1, string star2, string producer, string director, string productionCo, int setInStock, int videoid)设置硬碟的属性int getNoOfCopiesInStock() 取得硬碟的拷贝数量void checkOut()借出一张硬碟,列表中拷贝的数量减1vo

5、id checkIn()登记一张硬碟,列表中拷贝的数量加1void printTitle()输出硬碟的片名void printInfo()输出硬碟的细节信息bool checkTitle(string title)检查片名是否与硬碟的片名相同void updateInStock(int num)按数量增加列表中硬碟拷贝数void setCopiesInStock(int num)设置列表中硬碟拷贝的数量VideoListType类:函数模块功能bool videoSearch(string title);按片名查找影碟是否在商店中bool isVideoAvailable(string tit

6、le);若某张影碟至少有一个拷贝在商店中则返回truevoid videoCheckOut(string title);取出一张要借出的影碟,拷贝数减1,即copiesInStock=copiesInStock-1void videoCheckIn(string title);归还一张影碟,拷贝数加1bool videoCheckTitle(string title);若某张影碟在商店中则返回true,即copiesInStock=copiesInStock+1void videoUpdateInStock(string title, int num);按数值增加某张影碟的拷贝数,即copie

7、sInStock=copiesInStock+numvoid videoSetCopiesInStock(string title, int num);重新设置某张影碟的拷贝数,即copiesInStock=numvoid videoPrintTitle();输出影碟的片名void print();输入库中所有的影碟信息void videoInformation(string title);输出某影碟的具体信息int VideoID(string title);返回编号void searchVideoList(string title, bool &found, list:iterator &

8、current);在影碟列表中,按照影碟名查找特定的影碟,如果找到则设置found为true,否则为false2、 顾客顾客对象描述影碟相关的通常属性,如下:string Name; /姓名 int Number; /账号 int VideoID50; /此顾客所出租的影碟音像店系统管理程序中有关顾客的类:类基类说明CustomerType无一位顾客CustomerListTypelist顾客列表,CustomerType对象的列表,继承于STL标准列表容器CustomerType类:函数模块功能void setCustomerInfo(string name, int number, int

9、 videoid); 设置属性bool checkName(string name);检测是否有这名顾客int getName();显示账号void Rental(int id);出租影碟void Back(int id);返回影碟void Show();显示顾客的信息CustomerListType类:函数模块功能void CustomerShowNumber(string name);显示账号void CustomerRental(string name, int ID);出租一张影碟void CustomerBack(string name, int ID);返回一张影碟void Cus

10、tomerShow(string title);显示顾客的信息bool CustomerJudge(string name);判断顾客是否为会员void searchCustomerList(string title, bool &found, list:iterator ¤t);在顾客列表中,按照特定姓名查找特定的账号如果找到则设置found为true,否则为false设计方案: 首先设置4个类,然后利用case语句对各个函数进行调用。在这里过程中,保存顾客类的数据。当输入15时,结束程序。系统主要流程图:实现记录:1、进入主界面:2、各个功能的实现:(这里只是显示部分功能)C+

11、源代码主程序:#include #include #include #include VideoType.h#include VideoListType.h#include CustomerType.h#include CustomerListType.husing namespace std;/从输入文件中读取数据并创建影碟列表void createVideoList(ifstream &infile, VideoListType &videolist) char title50, star150, star250, producer50, director50, productionco7

12、0, ch; int instock, videoid; VideoType newvideo; infile.get(title, 50); infile.get(ch); while (infile) infile.get(star1, 50); infile.get(ch); infile.get(star2, 50); infile.get(ch); infile.get(producer, 50); infile.get(ch); infile.get(director, 50); infile.get(ch); infile.get(productionco, 50); infil

13、e.get(ch); infile instock; infile.get(ch); infile videoid; infile.get(ch); newvideo.setVideoInfo(title, star1, star2, producer, director, productionco, instock, videoid); videolist.push_back(newvideo); infile.get(title, 50); infile.get(ch); void displayMenu() cout 选择下列一项: endl; cout 1: 查找影碟 endl; co

14、ut 2: 借出影碟 endl; cout 3: 归还影碟 endl; cout 4: 库存查询 endl; cout 5: 打印所有影碟名称 endl; cout 6: 打印所有影碟详情 endl; cout 7: 显示某张特定影碟的影碟清单 endl; cout 8: 重新设置某张影碟的数量 endl; cout 9: 增加某张影碟的数量 endl; cout 10: 查询顾客的信息 endl; cout 11: 注册新顾客 endl; cout 12: 顾客出租一张影碟 endl; cout 13: 顾客返回一张影碟 endl; cout 14: 顾客账号查询 endl; cout 15

15、: 退出 endl;int Member = 0;/从文件中写入注册的新会员void login(CustomerListType &customerlist) Member+; char name50; int title50 = 0; CustomerType customer; cout 输入新会员的名字: name; customer.setCustomerInfo(name, Member, title); customerlist.push_back(customer); cout 注册成功!会员号为: Member endl endl;int main() VideoListTy

16、pe videolist; CustomerListType customerlist; int choice, number; char ch, title50, name50; ifstream infile; /打开输入文件 infile.open(VideoData.txt); if (!infile) cout 输入文件不存在! endl; return 1; /创建影碟列表 createVideoList(infile, videolist); infile.close(); /显示菜单 displayMenu(); cout 输入选项: choice; /处理输入 while (

17、choice != 15) switch (choice) case 1: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); if (videolist.videoSearch(title) cout 找到该影碟。 endl endl; else cout 该影碟不在库中。 endl endl; break; case 2: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); if (videolist.videoSearch(title) if (videolist.isVideoAva

18、ilable(title) videolist.videoCheckOut(title); cout 借出影碟: title endl endl; else cout 该影碟库存不足。 endl endl; else cout 库中没有该影碟。 endl endl; break; case 3: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); if (videolist.videoSearch(title) videolist.videoCheckIn(title); cout 感谢归还影碟 title endl endl; else c

19、out 库中没有该影碟。 endl endl; break; case 4: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); if (videolist.videoSearch(title) if (videolist.isVideoAvailable(title) cout 该影碟还有库存。 title endl endl; else cout 该影碟已经借光。 endl endl; else cout 库中没有该影碟。 endl endl; break; case 5: videolist.videoPrintTitle(); bre

20、ak; case 6: videolist.print(); break; case 7: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); videolist.videoInformation(title); break; case 8: cout 输入影碟名称: endl; cin.get(ch); cin.get(title, 50); cout 请输入影碟最新的数量数: number; videolist.videoSetCopiesInStock(title, number); cout endl; break; case 9:

21、cout 输入影碟的名称: endl; cin.get(ch); cin.get(title, 50); cout 请输入 title 影碟增加的数量数: number; videolist.videoUpdateInStock(title, number); cout endl; break; case 10: cout 输入顾客的名字: endl; cin.get(ch); cin.get(name, 50); customerlist.CustomerShow(name); cout endl; break; case 11: login(customerlist); break; ca

22、se 12: cout 输入顾客的名字: endl; cin.get(ch); cin.get(name, 50); if (customerlist.CustomerJudge(name) cout 输入需借出的影碟名称: endl; cin.get(ch); cin.get(title, 50); if (videolist.videoCheckTitle(title) videolist.videoCheckOut(title); number = videolist.VideoID(title); customerlist.CustomerRental(name, number); e

23、lse cout 对不起,音像店没有此 title 影碟。 endl; else cout 对不起,请注册成为会员! endl; cout endl; break; case 13: cout 输入顾客的名字: endl; cin.get(ch); cin.get(name, 50); cout 输入返回的影碟名称: endl; cin.get(ch); cin.get(title, 50); videolist.videoCheckIn(title); number = videolist.VideoID(title); customerlist.CustomerBack(name, num

24、ber); cout endl; break; case 14: cout 输入顾客名字: endl; cin.get(ch); cin.get(name, 50); customerlist.CustomerShowNumber(name); cout endl; break; default: cout 输入错误! endl endl; displayMenu(); cout 输入选项: choice; return 0;实验心得:此次实验是自己第一次利用面向对象程序设计思想来编写程序。在整个过程中是十分成功的。不但完成了实验的要求,而且还更加深刻了自己对面向对象编程的思想:面向对象程序设

25、计是对数据的封装;范式(模板)的程序设计是对算法的封装。利用面向对象思想编程是可以简化程序员的懒惰,无论是对象,还是函数,如果你输入有问题,那么都会在编译的时候报告出来,方便你修改,而不是在执行的时候出错,害的你到处去捉虫子。这就是用面向对象思想编程的好处。通过此次实验,学到了许多知识。 在这,十分感谢赵玉明老师的指导!附录:各类的源代码:#include #include #include VideoListType.hvoid VideoListType:searchVideoList(string title, bool &found, list:iterator ¤t) found = false; if (empty() cout 影碟列表为空! checkTitle(title) found = true; else current+; bool VideoListType:isVideoAvailable(string title) bool found; list:iterator location

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1