




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、.淮 海 工 學(xué) 院 計 算 機(jī) 工 程 學(xué) 院課程設(shè)計報告設(shè)計名稱: C+程序設(shè)計課程設(shè)計 姓 名: 學(xué) 號: 專業(yè)班級: 系 院: 設(shè)計時間: 設(shè)計地點: 成績:指導(dǎo)教師評語: 簽名: 年 月 日學(xué)習(xí)文檔 僅供參考1、課程設(shè)計目的 C+程序設(shè)計課程設(shè)計是電腦科學(xué)與技術(shù)專業(yè)重要的實踐性教學(xué)環(huán)節(jié)之一,本次設(shè)計結(jié)合實際應(yīng)用的要求,使課程設(shè)計既覆蓋C+的知識點,又接近工程實際需要。目的是通過課程設(shè)計的綜合訓(xùn)練,培養(yǎng)學(xué)生實際分析問題、解決問題的能力,以及編程和動手能力,最終目標(biāo)是通過課程設(shè)計這種形式,幫助學(xué)生系統(tǒng)掌握C+程序設(shè)計這門課程的主要內(nèi)容,養(yǎng)成良好的編程習(xí)慣,更好的完成教學(xué)任務(wù)。2、課程設(shè)計
2、任務(wù)與要求:本次課程設(shè)計利用C+程序設(shè)計課程中所學(xué)到的編程知識和編程技巧,完成具有一定難度和工作量的程序設(shè)計題目,幫助學(xué)生掌握編程、調(diào)試的基本技能,獨立完成所布置的任務(wù)。要求:1、對系統(tǒng)進(jìn)行功能需求分析2、設(shè)計合理的數(shù)據(jù)結(jié)構(gòu)和系統(tǒng)框架3、編程簡練,程序功能齊全,能正確運行4、說明書、流程圖要清楚5、課題完成后必須按要求提交課程設(shè)計報告任務(wù):設(shè)計一個商品銷售管理系統(tǒng)。運用C+語言描述商品類、供給商類。要求設(shè)計中綜合運用C+基礎(chǔ)知識,利用指針對商品、供給商鏈表進(jìn)行處理,方便快捷的進(jìn)行增刪改,充分利用友元來處理兩個類之間的關(guān)系,理解面向?qū)ο蟪绦蛟O(shè)計的核心的概念。實現(xiàn)功能:1建立商品類、供給商類2商品
3、、供給商信息的初始化3商品信息的添加、修改、刪除、 查找4供給商信息的添加、修改、刪除、查找5商品信息、供給商信息的輸出備注:將商品、供給商保存為文件,能夠?qū)懭肱c讀出。概要設(shè)計(1) 需求分析:要實現(xiàn)對商品,供給商信息的添加、修改、刪除、查找,并輸出信息,能夠方便快捷,并有用戶能詳細(xì)清楚的操作指南。2模塊說明:本次程序設(shè)計中,需要設(shè)計10個模塊,分別是添加、修改、刪除、查找、輸出商品信息和供給商信息,一共4個類:分別是商品類、商品數(shù)據(jù)類、供給商類、供給商數(shù)據(jù)類。通過幾個switch語句實現(xiàn)用戶選擇功能。主要函數(shù)流程圖:3詳細(xì)設(shè)計 商品數(shù)據(jù)類的設(shè)計class spData private: ch
4、ar name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()char *getName()int getCount()float getBuy() float getSale()char *getGys()void setId(int n)void setName(char na)void setCount(int c)void setBuy(float i)void setSale(float o) void setGys(char g);商品類的設(shè)計class Commodity
5、private:spData t50; int n;public:void newFile()int id;int n;char name50; int count;float iprice;float oprice; char gys20;if(n0) n=0; int i;spData temp; for(;n+)coutid;if(id=-1)break;tn.setId(id);coutname;tn.setName(name);coutcount;tn.setCount(count);coutiprice;tn.setBuy(iprice);coutoprice;tn.setSale
6、(oprice);coutgys;tn.setGys(gys); cout假設(shè)商品添加完畢,請按-1退出添加!endl;for(i=0;itn.getId()temp=ti;ti=tn;tn=temp;void showData(int i)spData t,*p;p=&t;coutgetId()setw(10)getName()setw(10)getCount()setw(8)getBuy()setw(8)getSale()setw(8)getGys()endl;void showData() int n;cout商品編號setw(8)商品名setw(8)庫存量setw(10)已售量setw
7、(10)進(jìn)價setw(8)售價setw(8)供給商endl;for(int i=0;i0 )showData(i);cout商品種類:nendl;void save() ofstream fout;fout.open(商品清單.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout商品編號 商品名 庫存量 進(jìn)價 售價 供給商 endl;for(int i=0;in;i+) foutti.getId()setw(14)ti.getName()setw(10)ti.getCount()setw(10)ti.getBuy()
8、setw(10)ti.getSale()setw(10)ti.getGys()endl;cout*Save Success!*endl;fout.close(); void xiugai() int count; char name100;float iprice;float oprice; char gys20;int temp;temp=search();if(temp=-1)coutcannot find the shopping!endl;return;else cout請輸入新數(shù)據(jù):endl;coutname;ttemp.setName(name);coutcount;ttemp.s
9、etCount(count);coutiprice;ttemp.setBuy(iprice);coutoprice;ttemp.setSale(oprice);coutgys;ttemp.setGys(gys);int search() int id;coutid;int low=0,mid,high=n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void remove() spData t10; cout請輸入要刪除的商品編號id; fstream file(商品清單.txt,ios:in|ios:out|ios:binary);f
10、or(int u=0;u5;u+)file.read(char*)&tu,sizeof(tu);for(int v=0;v5;v+) if(tv.id=id)continue;elsefile.write(char*)&tv,sizeof(tv);cout該商品被刪除endl;file.close();供給商數(shù)據(jù)類的設(shè)計class spData private: char name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()char *getName(char na)int getC
11、ount()float getBuy() float getSale()char *getGys()void setId(int n)void setName(char na)void setCount(int c)void setBuy(float i)void setSale(float o) void setGys(char g);供給商類的設(shè)計class gongyingshang private:gysData t50; int n; public:void newFile() int id;char name50;int phone;if(n0) n=0; for(;n+) cou
12、tid;if(id=-1)break;tn.setid();cout供給商名稱:;tn.setname(name);cout供給商 :;tn.setphone( ); cout假設(shè)供給商添加完畢,請按-1退出添加!endl;void showData(int i)gysData t,*p;p=&t;coutsetw(8)getid()setw(10)getname()setw(10)getphone()endl;void showData()coutsetw(8)供給商編號setw(8)供給商名稱setw(8)供給商 endl;for(int i=0;in;i+)showData(i);cou
13、t產(chǎn)品種類:nendl;void save()ofstream fout;fout.open(供給商.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout供給商編號 供給商 供給商 號 endl;for(int i=0;in;i+) foutti.getid()setw(10)ti.getname()setw(14)ti.getphone()endl;cout*Save Success!*endl;fout.close(); int search() int id;coutid;int low=0,mid,high=
14、n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void xiugai() char name100; int phone;int temp;temp=search();if(temp=-1)coutcannot find the gys!endl;return;else cout請輸入新數(shù)據(jù):endl;coutname;ttemp.setname(name);coutphone;ttemp.setphone(); void remove() gysData g10; cout請輸入要刪除的供給商編號id; fstream file(g
15、ys.txt,ios:in|ios:out|ios:binary);for(int u=0;u5;u+)file.read(char*)&gu,sizeof(gu);for(int v=0;v5;v+) if(gv.id=id)continue;elsefile.write(char*)&gv,sizeof(gv);cout該供給商被刪除endl;file.close();菜單函數(shù)的設(shè)計inline void menu2()system(cls);cout *歡送使用商品銷售管理系統(tǒng)* endl;cout *商品選項* endl;cout (1)添加 endl;cout (2)保存 endl;
16、cout (3)刪除 endl;cout (4)查找 endl; cout (5)信息輸出 endl; cout (6)修改 endl;cout (7)菜單 endl;cout (0)退出系統(tǒng) endl;cout *2012.6* endl; inline void menu1()system(cls); cout *歡送使用商品銷售管理系統(tǒng)* endl;cout *主菜單* endl;cout (1)商品選項 endl;cout (2)供給商選項 endl;cout (0)退出系統(tǒng) endl;cout *2012.6* endl; inline void menu3()system(cls)
17、;cout *歡送使用商品銷售管理系統(tǒng)* endl;cout *供給商選項* endl;cout (1)添加 endl;cout (2)保存 endl; cout (3)刪除 endl;cout (4)查找 endl; cout (5)信息輸出 endl; cout (6)修改 endl;cout (7)菜單 endl; cout (0)退出系統(tǒng) endl;cout *2012.6* endl;主函數(shù)的設(shè)計:int main()menu1();int x;coutx;switch(x)case 1:menu2();Commodity com;int c;for(;)coutc;switch(c
18、)case 1:com.newFile();break;case 2:com.save();break;case 3:com.remove();break; case 4:com.search;break; case 5:com.showData();break; case 6:menu1();break;case 0:cout *謝謝使用* endl;cout *!再見!* endl; break;case 2:menu3();gongyingshang gys;int c;for(;)coutc;switch(c)case 1:gys.newFile();break;case 2:gys.
19、save();break; case 3:gys.remove();break; case 4:gys.showData();break; case 5:gys.search();break;case 6:menu1();break;case 0:cout *謝謝使用* endl;cout *!再見!* endl; break;case 0:cout *謝謝使用* endl;cout *!再見!* endl; break;return 0;4調(diào)試分析:F:程序3.cpp(226) : warning C4700: local variable n used without having bee
20、n initializedF:程序3.cpp(246) : warning C4700: local variable c1 used without having been initializedF:程序3.cpp(348) : warning C4700: local variable g1 used without having been initializedC:Documents and SettingsAdministrator桌面q.cpp(237) : error C2562: search : void function returning a value C:Documen
21、ts and SettingsAdministrator桌面q.cpp(228) : see declaration of searchC:Documents and SettingsAdministrator桌面q.cpp(243) : error C2562: search : void function returning a value C:Documents and SettingsAdministrator桌面q.cpp(228) : see declaration of search(5)用戶使用說明手冊:1.進(jìn)入演示程序后,即顯示對話形式的提示操作過程: 如第一個選擇1 商品選
22、項 ,即顯示 1添加 2保存 3刪除 4查找 5信息輸出6修改 7菜單 0退出系統(tǒng) 選擇1,即顯示商品編號、商品名、庫存量、進(jìn)價、售價、供給商各項商品信息,一次輸入所添加的數(shù)據(jù)。添加完畢,按-1退出添加;選擇2,即將商品信息保存;選擇3,刪除要刪除的商品信息;選擇4,查找商品信息;選擇5,信息的輸出;選擇6,修改信息選擇7,返回到菜單;選擇0,退出系統(tǒng)。如第一個選擇2,供給商選項 ,同樣顯示 1添加 2保存 3刪除 4查找 5信息輸出6修改 7菜單 0退出系統(tǒng) 選擇數(shù)據(jù)的功能跟上面一樣。第一個選擇0 退出系統(tǒng)。6測試數(shù)據(jù)進(jìn)入演示程序后,即顯示對話形式的提示操作過程:選擇:1 商品選項選擇:1
23、添加商品選擇:2 保存信息選擇:3 刪除信息選擇:4 查找信息選擇:5 信息輸出選擇:6 修改選擇:0 退出系統(tǒng)選擇:2 供給商選項供給商信息的各選項跟商品信息的選項一樣。4課程設(shè)計成果程序源代碼#include#include#include#include #define Mfname 100#include #include #include #includeclass spData private: char name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()return
24、id;char *getName()return name;int getCount()return count;float getBuy()return iprice; float getSale()return oprice;char *getGys()return gys;void setId(int n)id=n;void setName(char na)strcpy(name,na);void setCount(int c)count=c; void setBuy(float i)iprice=i;void setSale(float o)oprice=o; void setGys(
25、char g) strcpy(gys,g);class gysDataprivate:char name100;int phone;public: int id;int getid()return id;char *getname()return name;int getphone()return phone;void setid()cinid;void setname(char na)strcpy(name,na);void setphone()cinphone;class Commodity private:spData t50; int n;public:void newFile()in
26、t id;int n;char name50; int count;float iprice;float oprice; char gys20;if(n0) n=0; int i;spData temp; for(;n+)coutid;if(id=-1)break;tn.setId(id);coutname;tn.setName(name);coutcount;tn.setCount(count);coutiprice;tn.setBuy(iprice);coutoprice;tn.setSale(oprice);coutgys;tn.setGys(gys); cout假設(shè)商品添加完畢,請按-
27、1退出添加!endl;for(i=0;itn.getId()temp=ti;ti=tn;tn=temp;void showData(int i)spData t,*p;p=&t;coutgetId()setw(10)getName()setw(10)getCount()setw(8)getBuy()setw(8)getSale()setw(8)getGys()endl;void showData() int n;cout商品編號setw(8)商品名setw(8)庫存量setw(10)已售量setw(10)進(jìn)價setw(8)售價setw(8)供給商endl;for(int i=0;i0 )sho
28、wData(i);cout商品種類:nendl;void save() ofstream fout;fout.open(商品清單.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout商品編號 商品名 庫存量 進(jìn)價 售價 供給商 endl;for(int i=0;in;i+) foutti.getId()setw(14)ti.getName()setw(10)ti.getCount()setw(10)ti.getBuy()setw(10)ti.getSale()setw(10)ti.getGys()endl;cout*
29、Save Success!*endl;fout.close(); void xiugai() int count; char name100;float iprice;float oprice; char gys20;int temp;temp=search();if(temp=-1)coutcannot find the shopping!endl;return;else cout請輸入新數(shù)據(jù):endl;coutname;ttemp.setName(name);coutcount;ttemp.setCount(count);coutiprice;ttemp.setBuy(iprice);co
30、utoprice;ttemp.setSale(oprice);coutgys;ttemp.setGys(gys);int search() int id;coutid;int low=0,mid,high=n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void remove() spData t10; cout請輸入要刪除的商品編號id; fstream file(商品清單.txt,ios:in|ios:out|ios:binary);for(int u=0;u5;u+)file.read(char*)&tu,sizeof(tu);f
31、or(int v=0;v5;v+) if(tv.id=id)continue;elsefile.write(char*)&tv,sizeof(tv);cout該商品被刪除endl;file.close();class gongyingshang private:gysData t50; int n; public:void newFile() int id;char name50;int phone;if(n0) n=0; for(;n+) coutid;if(id=-1)break;tn.setid();cout供給商名稱:;tn.setname(name);cout供給商 :;tn.setphone( ); cout假設(shè)供給商添加完畢,請按-1退出添加!endl;void showData(int i)gysData t,*p;p=&t;coutsetw(8)getid()setw(10)getname()setw(10)getphone()endl;void showData()coutsetw(8)供給商編號setw(8)供給商名稱setw(8)供給商 endl;for(int i=0;in;i+)showData(i);cout產(chǎn)品種類:nendl;void save
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度廠房出租合同(含金融融資支持)
- 2025年度車輛進(jìn)出口損害賠償協(xié)議范本
- 2025房產(chǎn)中介合伙人投資合作及退出機(jī)制合同
- 2025年理發(fā)、美容服務(wù)項目建議書
- 提高護(hù)理文書書寫規(guī)范的實施措施計劃
- 倉庫節(jié)能降耗工作的總結(jié)與展望計劃
- 新年自我反思與成長計劃
- 創(chuàng)造多元環(huán)境培養(yǎng)幼兒園小班的藝術(shù)表達(dá)能力計劃
- 調(diào)整工作節(jié)奏的方法計劃
- 經(jīng)驗教訓(xùn)與未來目標(biāo)的思考計劃
- 部編版二年級下冊語文教案全冊
- 解放牌汽車CA10B后鋼板彈簧吊耳加工工藝及夾具設(shè)計哈
- 高中地理高清區(qū)域地理填圖冊
- 培根鑄魂征文800字
- 連續(xù)梁0號塊施工課件
- 旋挖鉆機(jī)入場安全教育記錄
- 第二章直線和圓的方程(單元測試卷)(原卷版)
- 第二篇-安全操作規(guī)程
- 罪犯教育學(xué)課程
- 紀(jì)檢監(jiān)察辦案談話應(yīng)注意的問題研討
- 落實國家組織藥品集中采購使用檢測和應(yīng)急預(yù)案
評論
0/150
提交評論