音像店實(shí)驗(yàn)報(bào)告面向?qū)ο髮?shí)驗(yàn)報(bào)告_第1頁(yè)
音像店實(shí)驗(yàn)報(bào)告面向?qū)ο髮?shí)驗(yàn)報(bào)告_第2頁(yè)
音像店實(shí)驗(yàn)報(bào)告面向?qū)ο髮?shí)驗(yàn)報(bào)告_第3頁(yè)
音像店實(shí)驗(yàn)報(bào)告面向?qū)ο髮?shí)驗(yàn)報(bào)告_第4頁(yè)
音像店實(shí)驗(yàn)報(bào)告面向?qū)ο髮?shí)驗(yàn)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

面向?qū)ο蟪绦蛟O(shè)計(jì)--面向?qū)ο蟪绦蛟O(shè)計(jì)姓名:班級(jí):10級(jí)計(jì)科班時(shí)間:2011年音像店管理系統(tǒng)程序設(shè)計(jì)實(shí)驗(yàn)項(xiàng)目名稱:音像店管理系統(tǒng)課程名稱:面向?qū)ο蟪绦蛟O(shè)計(jì)面向?qū)I(yè):計(jì)算機(jī)科學(xué)與技術(shù)實(shí)驗(yàn)?zāi)康模豪妹嫦驅(qū)ο蟪绦蛟O(shè)計(jì)思想編寫一個(gè)程序使得音像店可以正常工程。實(shí)驗(yàn)?zāi)繕?biāo)與要求:程序應(yīng)該執(zhí)行以下操作:出租影碟。返還影碟。創(chuàng)建音像商店擁有的影碟清單。打印商店所有硬碟的清單。顯示某張?zhí)囟ㄓ暗那鍐?。檢查某張影碟是否在商店中。維護(hù)顧客的數(shù)據(jù)庫(kù)。打印每位顧客所租的所有影碟清單。實(shí)驗(yàn)環(huán)境要求:VC++6.0實(shí)驗(yàn)儀器設(shè)備:一臺(tái)計(jì)算機(jī)實(shí)驗(yàn)語(yǔ)言:C++實(shí)驗(yàn)內(nèi)容:程序需求表明音像店有2個(gè)主要組成部分:影碟和顧客。程序在描述這2個(gè)組成部分的同時(shí)還需要生成以下2個(gè)列表:商店所有影碟的列表。商店所有顧客的列表。在這里分2個(gè)部分分析,第1部分設(shè)計(jì)、實(shí)現(xiàn)和測(cè)試影碟部分,第2部分設(shè)計(jì)和實(shí)現(xiàn)顧客部分并加入到第1部分開發(fā)的影碟部分。影碟影碟對(duì)象描述影碟相關(guān)的通常屬性,如下: stringvideoTitle;//片名 stringmovieStar1;//明星1 stringmovieStar2;//明星2 stringmovieProducer;//制片人 stringmovieDirector;//導(dǎo)演 stringmovieProductionCo;//制片公司 intcopiesInStock;//列表中拷貝的數(shù)量 intVideoID;//影碟的編號(hào)音像店系統(tǒng)管理程序中有關(guān)影碟的類:類基類說(shuō)明VideoType無(wú)一張影碟VideoListTypelist影碟列表,VideoType對(duì)象的列表,繼承于STL標(biāo)準(zhǔn)列表容器VideType類:函數(shù)模塊功能成員說(shuō)明stringvideoTitle片名stringmovieStar1明星1stringmovieStar2明星2stringmovieProducer制片人stringmovieDirector導(dǎo)演stringmovieProductionCo制片公司intcopiesInStock列表中拷貝的數(shù)量intVideoID影碟的編號(hào)voidsetVideoInfo(stringtitle,stringstar1,stringstar2,stringproducer,

stringdirector,stringproductionCo,intsetInStock,intvideoid)設(shè)置硬碟的屬性intgetNoOfCopiesInStock()取得硬碟的拷貝數(shù)量voidcheckOut()借出一張硬碟,列表中拷貝的數(shù)量減1voidcheckIn()登記一張硬碟,列表中拷貝的數(shù)量加1voidprintTitle()輸出硬碟的片名voidprintInfo()輸出硬碟的細(xì)節(jié)信息boolcheckTitle(stringtitle)檢查片名是否與硬碟的片名相同voidupdateInStock(intnum)按數(shù)量增加列表中硬碟拷貝數(shù)voidsetCopiesInStock(intnum)設(shè)置列表中硬碟拷貝的數(shù)量VideoListType類:函數(shù)模塊功能boolvideoSearch(stringtitle);按片名查找影碟是否在商店中boolisVideoAvailable(stringtitle);若某張影碟至少有一個(gè)拷貝在商店中則返回truevoidvideoCheckOut(stringtitle);取出一張要借出的影碟,拷貝數(shù)減1,即copiesInStock=copiesInStock-1voidvideoCheckIn(stringtitle);歸還一張影碟,拷貝數(shù)加1boolvideoCheckTitle(stringtitle);若某張影碟在商店中則返回true,即copiesInStock=copiesInStock+1voidvideoUpdateInStock(stringtitle,intnum);按數(shù)值增加某張影碟的拷貝數(shù),即copiesInStock=copiesInStock+numvoidvideoSetCopiesInStock(stringtitle,intnum);重新設(shè)置某張影碟的拷貝數(shù),即copiesInStock=numvoidvideoPrintTitle();輸出影碟的片名voidprint();輸入庫(kù)中所有的影碟信息voidvideoInformation(stringtitle);輸出某影碟的具體信息intVideoID(stringtitle);返回編號(hào)voidsearchVideoList(stringtitle,bool&found,list<VideoType>::iterator¤t);在影碟列表中,按照影碟名查找特定的影碟,如果找到則設(shè)置found為true,否則為false顧客顧客對(duì)象描述影碟相關(guān)的通常屬性,如下:stringName;//姓名 intNumber;//賬號(hào) intVideoID[50];//此顧客所出租的影碟音像店系統(tǒng)管理程序中有關(guān)顧客的類:類基類說(shuō)明CustomerType無(wú)一位顧客CustomerListTypelist顧客列表,CustomerType對(duì)象的列表,繼承于STL標(biāo)準(zhǔn)列表容器CustomerType類:函數(shù)模塊功能voidsetCustomerInfo(stringname,intnumber,intvideoid[]);設(shè)置屬性boolcheckName(stringname);檢測(cè)是否有這名顧客intgetName();顯示賬號(hào)voidRental(intid);出租影碟voidBack(intid);返回影碟voidShow();顯示顧客的信息CustomerListType類:函數(shù)模塊功能voidCustomerShowNumber(stringname);顯示賬號(hào)voidCustomerRental(stringname,intID);出租一張影碟voidCustomerBack(stringname,intID);返回一張影碟voidCustomerShow(stringtitle);顯示顧客的信息boolCustomerJudge(stringname);判斷顧客是否為會(huì)員voidsearchCustomerList(stringtitle,bool&found,list<CustomerType>::iterator¤t);在顧客列表中,按照特定姓名查找特定的賬號(hào)如果找到則設(shè)置found為true,否則為false設(shè)計(jì)方案:首先設(shè)置4個(gè)類,然后利用case語(yǔ)句對(duì)各個(gè)函數(shù)進(jìn)行調(diào)用。在這里過(guò)程中,保存顧客類的數(shù)據(jù)。當(dāng)輸入15時(shí),結(jié)束程序。系統(tǒng)主要流程圖:開始開始(選擇choice)進(jìn)行choice所對(duì)應(yīng)的函數(shù)進(jìn)行調(diào)用,并且輸出結(jié)果進(jìn)入歡迎界面,選擇要進(jìn)行操作的選項(xiàng)編號(hào)i判斷choice值對(duì)應(yīng)case調(diào)用相應(yīng)的函數(shù)當(dāng)choice輸入15退出程序結(jié)束面向?qū)ο蟪绦蛟O(shè)計(jì)音像店管理系統(tǒng)程序流程圖簡(jiǎn)圖實(shí)現(xiàn)記錄:1、進(jìn)入主界面:2、各個(gè)功能的實(shí)現(xiàn):(這里只是顯示部分功能)C++源代碼主程序:#include<vector>#include<fstream>#include<string.h>#include"VideoType.h"#include"VideoListType.h"#include"CustomerType.h"#include"CustomerListType.h"usingnamespacestd;//從輸入文件中讀取數(shù)據(jù)并創(chuàng)建影碟列表voidcreateVideoList(ifstream&infile,VideoListType&videolist){ chartitle[50],star1[50],star2[50],producer[50],director[50],productionco[70],ch; intinstock,videoid; VideoTypenewvideo; 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); infile.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); }}voiddisplayMenu(){ cout<<"選擇下列一項(xiàng):"<<endl; cout<<"1:查找影碟"<<endl; cout<<"2:借出影碟"<<endl; cout<<"3:歸還影碟"<<endl; cout<<"4:庫(kù)存查詢"<<endl; cout<<"5:打印所有影碟名稱"<<endl; cout<<"6:打印所有影碟詳情"<<endl; cout<<"7:顯示某張?zhí)囟ㄓ暗挠暗鍐?<<endl; cout<<"8:重新設(shè)置某張影碟的數(shù)量"<<endl; cout<<"9:增加某張影碟的數(shù)量"<<endl; cout<<"10:查詢顧客的信息"<<endl; cout<<"11:注冊(cè)新顧客"<<endl; cout<<"12:顧客出租一張影碟"<<endl; cout<<"13:顧客返回一張影碟"<<endl; cout<<"14:顧客賬號(hào)查詢"<<endl; cout<<"15:退出"<<endl;}intMember=0;//從文件中寫入注冊(cè)的新會(huì)員voidlogin(CustomerListType&customerlist){ Member++; charname[50]; inttitle[50]={0}; CustomerTypecustomer; cout<<"輸入新會(huì)員的名字:"<<endl; cin>>name; customer.setCustomerInfo(name,Member,title); customerlist.push_back(customer); cout<<"注冊(cè)成功!會(huì)員號(hào)為:"<<Member<<endl<<endl;}intmain(){ VideoListTypevideolist; CustomerListTypecustomerlist; intchoice,number; charch,title[50],name[50]; ifstreaminfile; //打開輸入文件 infile.open("VideoData.txt"); if(!infile) { cout<<"輸入文件不存在!"<<endl; return1; } //創(chuàng)建影碟列表 createVideoList(infile,videolist); infile.close(); //顯示菜單 displayMenu(); cout<<"輸入選項(xiàng):"<<endl; cin>>choice; //處理輸入 while(choice!=15) { switch(choice) { case1: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); if(videolist.videoSearch(title)) { cout<<"找到該影碟。"<<endl<<endl; } else { cout<<"該影碟不在庫(kù)中。"<<endl<<endl; } break; case2: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); if(videolist.videoSearch(title)) { if(videolist.isVideoAvailable(title)) { videolist.videoCheckOut(title); cout<<"借出影碟:"<<title<<endl<<endl; } else { cout<<"該影碟庫(kù)存不足。"<<endl<<endl; } } else { cout<<"庫(kù)中沒(méi)有該影碟。"<<endl<<endl; } break; case3: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); if(videolist.videoSearch(title)) { videolist.videoCheckIn(title); cout<<"感謝歸還影碟"<<title<<endl<<endl; } else { cout<<"庫(kù)中沒(méi)有該影碟。"<<endl<<endl; } break; case4: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); if(videolist.videoSearch(title)) { if(videolist.isVideoAvailable(title)) { cout<<"該影碟還有庫(kù)存。"<<title<<endl<<endl; } else { cout<<"該影碟已經(jīng)借光。"<<endl<<endl; } } else { cout<<"庫(kù)中沒(méi)有該影碟。"<<endl<<endl; } break; case5: videolist.videoPrintTitle(); break; case6: videolist.print(); break; case7: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); videolist.videoInformation(title); break; case8: cout<<"輸入影碟名稱:"<<endl; cin.get(ch); cin.get(title,50); cout<<"請(qǐng)輸入影碟最新的數(shù)量數(shù):"<<endl; cin>>number; videolist.videoSetCopiesInStock(title,number); cout<<endl; break; case9: cout<<"輸入影碟的名稱:"<<endl; cin.get(ch); cin.get(title,50); cout<<"請(qǐng)輸入<<"<<title<<">>影碟增加的數(shù)量數(shù):"<<endl; cin>>number; videolist.videoUpdateInStock(title,number); cout<<endl; break; case10: cout<<"輸入顧客的名字:"<<endl; cin.get(ch); cin.get(name,50); customerlist.CustomerShow(name); cout<<endl; break; case11: login(customerlist); break; case12: 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); } else { cout<<"對(duì)不起,音像店沒(méi)有此"<<"<<"<<title<<">>"<<"影碟。"<<endl; } } else { cout<<"對(duì)不起,請(qǐng)注冊(cè)成為會(huì)員!"<<endl; } cout<<endl; break; case13: 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,number); cout<<endl; break; case14: cout<<"輸入顧客名字:"<<endl; cin.get(ch); cin.get(name,50); customerlist.CustomerShowNumber(name); cout<<endl; break; default: cout<<"輸入錯(cuò)誤!"<<endl<<endl; } displayMenu(); cout<<"輸入選項(xiàng):"<<endl; cin>>choice; } return0;}實(shí)驗(yàn)心得:此次實(shí)驗(yàn)是自己第一次利用面向?qū)ο蟪绦蛟O(shè)計(jì)思想來(lái)編寫程序。在整個(gè)過(guò)程中是十分成功的。不但完成了實(shí)驗(yàn)的要求,而且還更加深刻了自己對(duì)面向?qū)ο缶幊痰乃枷耄好嫦驅(qū)ο蟪绦蛟O(shè)計(jì)是對(duì)數(shù)據(jù)的封裝;范式(模板)的程序設(shè)計(jì)是對(duì)算法的封裝。利用面向?qū)ο笏枷刖幊淌强梢院?jiǎn)化程序員的懶惰,無(wú)論是對(duì)象,還是函數(shù),如果你輸入有問(wèn)題,那么都會(huì)在編譯的時(shí)候報(bào)告出來(lái),方便你修改,而不是在執(zhí)行的時(shí)候出錯(cuò),害的你到處去捉蟲子。

這就是用面向?qū)ο笏枷刖幊痰暮锰?。通過(guò)此次實(shí)驗(yàn),學(xué)到了許多知識(shí)。

在這,十分感謝趙玉明老師的指導(dǎo)!附錄:各類的源代碼:#include<list>#include<string>#include"VideoListType.h"voidVideoListType::searchVideoList(stringtitle,bool&found,list<VideoType>::iterator¤t){ found=false; if(empty()) { cout<<"影碟列表為空!"<<endl; } else { current=begin(); found=false; while(!found&¤t!=end()) { if(current->checkTitle(title)) { found=true; } else { current++; } } }}boolVideoListType::isVideoAvailable(stringtitle){ boolfound; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { found=(location->getNoOfCopiesInStock()>0); } else { found=false; } returnfound;}voidVideoListType::videoCheckIn(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { location->checkIn(); } else { cout<<"影碟不在庫(kù)中!"<<endl<<endl; }}voidVideoListType::videoCheckOut(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { location->checkOut(); } else { cout<<"影碟不在庫(kù)中!"<<endl<<endl; }}boolVideoListType::videoCheckTitle(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); returnfound;}voidVideoListType::videoUpdateInStock(stringtitle,intnum){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { location->updateInStock(num); } else { cout<<"影碟不在庫(kù)中!"<<endl<<endl; }}voidVideoListType::videoSetCopiesInStock(stringtitle,intnum){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { location->setCopiesInStock(num); } else { cout<<"影碟不在庫(kù)中!"<<endl<<endl; }}boolVideoListType::videoSearch(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); returnfound;}voidVideoListType::videoInformation(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { location->printInfo(); } else { cout<<"此商店沒(méi)有該影碟"<<endl<<endl; }}voidVideoListType::videoPrintTitle(){ list<VideoType>::iteratorcurrent; current=begin(); while(current!=end()) { current->printTitle(); current++; }}intVideoListType::VideoID(stringtitle){ boolfound=false; list<VideoType>::iteratorlocation; searchVideoList(title,found,location); if(found) { returnlocation->back(); } else { cout<<"此商店沒(méi)有該影碟"<<endl<<endl; } return0;}voidVideoListType::print(){ list<VideoType>::iteratorcurrent; current=begin(); while(current!=end()) { current->printTitle(); current->printInfo(); cout<<""<<endl<<endl; current++; }}#include"VideoType.h"voidVideoType::setVideoInfo(stringtitle,stringstar1,stringstar2,stringproducer, stringdirector,stringproductionCo,intsetInStock,intvideoid){ videoTitle=title; movieStar1=star1; movieStar2=star2; movieProducer=producer; movieDirector=director; movieProductionCo=productionCo; copiesInStock=setInStock; VideoID=videoid;}voidVideoType::checkOut(){ if(getNoOfCopiesInStock()>0) { copiesInStock--; } else { cout<<"影碟被借完"<<endl<<endl; }}voidVideoType::checkIn(){ copiesInStock++;}intVideoType::getNoOfCopiesInStock()const{ returncopiesInStock;}voidVideoType::printTitle()const{ cout<<"片名:"<<videoTitle<<endl<<endl;}voidVideoType::printInfo()const{ cout<<"片名: "<<videoTitle<<endl; cout<<"影碟編號(hào): "<<VideoID<<endl; cout<<"明星: "<<movieStar1<<" "<<movieStar2<<endl; cout<<"演員: "<<movieDirector<<endl; cout<<"制片: "<<movieProducer<<endl; cout<<"制片公司: "<<movieProductionCo<<endl; cout<<"拷貝數(shù): "<<copiesInStock<<endl; cout<<endl;}boolVideoType::checkTitle(stringtitle){ return(videoTitle==title);}voidVideoType::updateInStock(intnum){ copiesInStock+=num;}voidVideoType::setCopiesInStock(intnum){ copiesInStock=num;}VideoType::videoType(stringtitle,stringstar1,stringstar2,stringproducer, stringdirector,stringproductionCo,intsetInStock,intvideoid){ videoTitle=title; movieStar1=star1; movieStar2=star2; movieProducer=producer; movieDirector=director; movieProductionCo=productionCo; copiesInStock=setInStock; VideoID=videoid;}intVideoType::back(){ returnVideoID;}boolVideoType::operator==(VideoTypeother){ return(videoTitle==other.videoTitle);}boolVideoType::operator!=(VideoTypeother){ return(videoTitle!=other.videoTitle);}#include"VideoType.h"#include"VideoListType.h"#include"CustomerType.h"#include"CustomerListType.h"voidCustomerListType::searchCustomerList(stringname,bool&found,list<CustomerType>::iterator¤t){ found=false; if(empty()) { cout<<"顧客列表為空!"<<endl; } else { current=begin(); found=false; while(!found&¤t!=end()) { if(current->checkName(name)) { found=true; } else { current++; } } }}boolCustomerListType::CustomerJudge(stringname){ boolfound=false; list<CustomerType>::iteratorloaction; searchCustomerList(name,found,loaction); returnfound;}voidCustomerListType::CustomerShowNumber(stringname){ boolfound=false; list<CustomerType>::iteratorlocation; searchCustomerList(name,found,location); if(found) { cout<<"此會(huì)員的賬號(hào)為:"<<location->getName()<<endl; } else { cout<<"對(duì)不起,沒(méi)有此會(huì)員的記錄!"<<endl; }}voidCustomerListType::CustomerRental(stringname,intID){ boolfound=

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論