![C++課程設(shè)計(jì)-小型超市管理系統(tǒng)_第1頁(yè)](http://file4.renrendoc.com/view/95b8ff2f8bb9b140d2d2bb06370be467/95b8ff2f8bb9b140d2d2bb06370be4671.gif)
![C++課程設(shè)計(jì)-小型超市管理系統(tǒng)_第2頁(yè)](http://file4.renrendoc.com/view/95b8ff2f8bb9b140d2d2bb06370be467/95b8ff2f8bb9b140d2d2bb06370be4672.gif)
![C++課程設(shè)計(jì)-小型超市管理系統(tǒng)_第3頁(yè)](http://file4.renrendoc.com/view/95b8ff2f8bb9b140d2d2bb06370be467/95b8ff2f8bb9b140d2d2bb06370be4673.gif)
![C++課程設(shè)計(jì)-小型超市管理系統(tǒng)_第4頁(yè)](http://file4.renrendoc.com/view/95b8ff2f8bb9b140d2d2bb06370be467/95b8ff2f8bb9b140d2d2bb06370be4674.gif)
![C++課程設(shè)計(jì)-小型超市管理系統(tǒng)_第5頁(yè)](http://file4.renrendoc.com/view/95b8ff2f8bb9b140d2d2bb06370be467/95b8ff2f8bb9b140d2d2bb06370be4675.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
頁(yè)摘要
當(dāng)代社會(huì)中伴隨著計(jì)算機(jī)技術(shù)在各行各業(yè)日益廣泛和深入的應(yīng)用,超市對(duì)貨品于職員的管理不在像過(guò)去一樣靠手工去做,在一些超市管理中也開(kāi)始信息化。信息化的管理可以為超市節(jié)省大量人力物力,提高其運(yùn)行效率,從而為顧客提供更好的服務(wù),實(shí)現(xiàn)超市的業(yè)務(wù)提升。
本系統(tǒng)就是為了適應(yīng)這種要求而設(shè)計(jì)的。集信息的顯示、輸入、修改、刪除、查詢等各種處理為一體,信息維護(hù)起來(lái)非常方便。大大減少了超市的人力和物力。
本系統(tǒng)大致要做到以下幾點(diǎn):
(1)
操作簡(jiǎn)便,節(jié)省大量人力;
(2)可以方便的進(jìn)行貨品管理,安全、高效;
(3)
可以迅速計(jì)算銷售額和所買賣貨品;
(4)
可以迅速查到所需信息,便于管理1概述1.1任務(wù):
超市管理系統(tǒng)對(duì)職員商品信息進(jìn)行高效簡(jiǎn)潔的管理,使之能正常高效的進(jìn)行售賣活動(dòng)。系統(tǒng)充分考慮到超市管理系統(tǒng)對(duì)貨物資料進(jìn)行登記并處理。考慮到進(jìn)貨、退貨、庫(kù)存預(yù)警、年月日銷售額結(jié)算等多種特殊情況,同時(shí)可將相關(guān)資料進(jìn)行有效處理。1.2目標(biāo):
當(dāng)代社會(huì)中伴隨著計(jì)算機(jī)技術(shù)在各行各業(yè)日益廣泛和深入的應(yīng)用,超市對(duì)貨品于職員的管理不在像過(guò)去一樣靠手工去做,在一些超市管理中也開(kāi)始信息化。信息化的管理可以為超市節(jié)省大量人力物力,提高其運(yùn)行效率,從而為顧客提供更好的服務(wù),實(shí)現(xiàn)超市的業(yè)務(wù)提升。
本系統(tǒng)就是為了適應(yīng)這種要求而設(shè)計(jì)的。集信息的顯示、輸入、修改、刪除、查詢等各種處理為一體,信息維護(hù)起來(lái)非常方便。大大減少了超市的人力和物力。
本系統(tǒng)大致要做到以下幾點(diǎn):
(1)
操作簡(jiǎn)便,節(jié)省大量人力;
(2)可以方便的進(jìn)行貨品管理,安全、高效;
(3)
可以迅速計(jì)算銷售額和所買賣貨品;
(4)
可以迅速查到所需信息,便于管理。2.設(shè)計(jì)方案簡(jiǎn)述2.1設(shè)計(jì)內(nèi)容設(shè)計(jì)一個(gè)簡(jiǎn)單的超市管理系統(tǒng)。1.暫定有三個(gè)貨架,分別放著日常用品、食品和家電。2.可以實(shí)貨架商品的增加和出售。3.設(shè)計(jì)查詢功能,可以查找商品的現(xiàn)狀。4.不同商品有不同屬性:食品類,保質(zhì)期,家電,顏色。5.重載運(yùn)算符>>。2.2設(shè)計(jì)目的與要求2.2.1設(shè)計(jì)目的達(dá)到熟練掌握C++語(yǔ)言的基本知識(shí)和技能;基本掌握面向?qū)ο蟪绦蛟O(shè)計(jì)的基本思路和方法;能夠利用所學(xué)的基本知識(shí)和技能,解決簡(jiǎn)單的面向?qū)ο蟪绦蛟O(shè)計(jì)問(wèn)題。2.2.2設(shè)計(jì)要求要求利用面向?qū)ο蟮姆椒ㄒ约癈++的編程思想來(lái)完成系統(tǒng)的設(shè)計(jì);要求在設(shè)計(jì)的過(guò)程中,建立清晰的類層次;在系統(tǒng)的設(shè)計(jì)中,至少要用到面向?qū)ο蟮囊环N機(jī)制。2.3 系統(tǒng)分析與設(shè)計(jì)2.3.1主要知識(shí)點(diǎn)1)類,類內(nèi)包含構(gòu)造函數(shù)、成員函數(shù)、私有數(shù)據(jù)成員和某些輸入輸出函數(shù);2)運(yùn)算符重載,定義一個(gè)重載運(yùn)算符的函數(shù),在需要執(zhí)行被重載的運(yùn)算符是,系統(tǒng)自動(dòng)調(diào)用該函數(shù);3)繼承與派生:1.基類即父類,被繼承的已有類;2.派生類即子類,新建立的類;3.這些類的定義和聲明同類;4.虛函數(shù)的作用是允許在派生類中重新定義與基類同名的函數(shù),并且可以通過(guò)基類指針或引用來(lái)訪問(wèn)基類和派生類中的同名函數(shù)。2.3.2關(guān)鍵技術(shù)1)程序共有四個(gè)頭文件和四個(gè)源文件。頭文件Supermarket,包含增加Add,出售Sale和查詢Search三個(gè)公有成員函數(shù);源文件Supermarket,增加函數(shù),出售函數(shù)和查詢函數(shù)的功能相似,選擇功能,輸出商品類型列表。頭文件Goods,在這個(gè)頭文件中有四個(gè)類,一個(gè)基類和三個(gè)派生類?;怗oods中設(shè)置增加AddGoods,出售SaleGoods,顯示函數(shù)virtualShowMe。同時(shí)定義統(tǒng)一的出售函數(shù)Sale。保護(hù)成員包括,商品名稱name[],商品數(shù)量number[]和商品分類的數(shù)量count。派生類,日常用品類DailyGoods,食物Food和家電ElectricalAppliance,除了自身的無(wú)參構(gòu)造函數(shù),均從基類中繼承增加AddGoods,出售SaleGoods,顯示函數(shù)virtualShowMe,并根據(jù)課題要求加入運(yùn)算符重載函數(shù)istreamoperator>>(istream&in,DailyGoods&d)。同時(shí)借助函數(shù)Input_file和函數(shù)Save_file將商品信息輸出并保存到文件中。源文件Goods,實(shí)現(xiàn)各函數(shù)功能。頭文件diaplay,保存了小系統(tǒng)的基本頁(yè)面和選擇頁(yè)面。登錄界面Loading,功能選擇界面SelectMenu,商品功能列表GoodList和結(jié)束頁(yè)面End。源文件display,進(jìn)行頭文件的各項(xiàng)函數(shù)的功能實(shí)現(xiàn)。頭文件file,是關(guān)于文件的存儲(chǔ),打開(kāi)和關(guān)閉的功能。源文件main,實(shí)現(xiàn)功能的匯總和實(shí)現(xiàn)方式。2)部分函數(shù)的實(shí)現(xiàn)//Supermaket*Add函數(shù)intSupermarket::Add(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您要增加什么類型的商品?"; cin>>Good_num; returnGood_num;}*Sale函數(shù)intSupermarket::Sale(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您要出售什么類型的商品?"; cin>>Good_num; returnGood_num;}*Search函數(shù)intSupermarket::Search(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您想要查詢什么類型的商品?"; cin>>Good_num; returnGood_num;}//Goods*Sale函數(shù)voidGoods::Sale()//統(tǒng)一定義商品出售函數(shù)功能模塊{ intflag=0; stringgoods_name; intgoods_number; cout<<"商品名稱:";cin>>goods_name;cout<<"出售數(shù)量:";cin>>goods_number; for(inti=0;i<count;i++)//count在Goods.h中定義的保護(hù)成員 { if(name[i]==goods_name) { if(number[i]<goods_number) { flag=1; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!貨存不足!!!"<<endl; } else { flag=1; number[i]-=goods_number; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!出售成功!!!"<<endl; } } } if(flag==0) { getchar(); cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t沒(méi)有該物品!"<<endl; getchar(); }}*AddGoods函數(shù)voidDailyGoods::AddGoods()//增加日常用品{ system("cls"); intflag=1; ShowMe(); cout<<endl<<"\t\t>>>>>>>>請(qǐng)輸入要增加日常用品的信息<<<<<<<<<"<<endl<<endl; cout<<"商品名稱:";cin>>name[count]; cout<<"商品數(shù)量:";cin>>number[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否已經(jīng)存在 { number[i]+=number[count]; flag=0; } } if(flag) count++;//用于新增物品 cout<<endl<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!添加商品成功!!!"<<endl; cout<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl;}voidFood::AddGoods()//增加食品{ system("cls"); intflag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入需要增加的食品信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl; cout<<"商品名稱:";cin>>number[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否存在 { number[i]+=number[count]; flag=0; } } if(flag) { cout<<"商品數(shù)量:";cin>>number[count]; cout<<"保質(zhì)期:";cin>>SaveTime[count]; count++;//用于新增物品 } cout<<endl<<endl<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl<<endl; cout<<"\t\t\t添加商品成功!!!"<<endl; cout<<endl<<endl<<endl<<endl; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl<<endl;}voidElectricalAppliance::AddGoods()//增加家電{ system("cls"); intflag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入要增加的家電的信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; cout<<"商品名稱:";cin>>name[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否已經(jīng)存在 { cout<<"商品數(shù)量:"; cin>>number[count]; number[i]+=number[count]; flag=0; } } if(flag) { cout<<"商品數(shù)量:"; cin>>number[count]; cout<<"顏色:"; cin>>color[count]; count++;//用于新增物品 } cout<<endl<<endl<<"\t\t*************************************"<<endl; cout<<"\t\t!!!添加商品成功!!!!"<<endl; cout<<"\t\t*************************************"<<endl;}*SaleGoods函數(shù)voidDailyGoods::SaleGoods()//出售日常用品{ system("cls"); ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入要出售的日常用品信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale()函數(shù)}voidFood::SaleGoods()//出售食品{ system("cls"); ShowMe(); cout<<endl<<"~~~~~~~~~~~~~~~~~~~~~~~~請(qǐng)輸入要出售的食品信息~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale函數(shù)}voidElectricalAppliance::SaleGoods()//賣出家電{ system("cls"); ShowMe(); cout<<endl<<">>>>>>>>請(qǐng)輸入要出售的家電信息>>>>>>>>"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale()函數(shù)}*ShowMe函數(shù)voidDailyGoods::ShowMe()//顯示日常用品{ cout<<endl<<"超市商品管理系統(tǒng)**日常用品區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有日常用品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"日常用品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"現(xiàn)存數(shù)量:"<<number[i]<<"個(gè)"<<endl; cout<<""<<endl; }}voidFood::ShowMe()//顯示食品信息{ cout<<endl<<"超市商品管理系統(tǒng)**食品區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有食品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"食品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i];//執(zhí)行由有參數(shù)指定區(qū)域內(nèi)的動(dòng)作 cout<<"現(xiàn)存數(shù)量:"<<setw(4)<<number[i]<<setw(8)<<"千克";//setw(n)設(shè)域?qū)挒閚個(gè)字符 cout<<"保質(zhì)期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; cout<<""<<endl; }}voidElectricalAppliance::ShowMe()//顯示家電信息{ cout<<endl<<"超市商品管理系統(tǒng)**家電區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有家電類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"家電名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"現(xiàn)存數(shù)量:"<<number[i]<<setw(6)<<"臺(tái)"; cout<<"顏色:"<<color[i]<<endl; cout<<""<<endl; }}*文件的輸入和保存函數(shù)voidDailyGoods::Input_file(ostream&outfile)//將DailyGoods類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有日常用品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"日常用品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<number[i]<<"個(gè)"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidDailyGoods::Save_file(ostream&Write_DailyGoods)//用于將DailyGoods商品信息單獨(dú)保存到文件中{ Write_DailyGoods<<count<<endl; for(inti=0;i<count;i++) { Write_DailyGoods<<name[i]<<""<<number[i]<<endl; }}voidFood::Input_file(ostream&outfile)//將Food類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有食品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"食品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<setw(4)<<number[i]<<setw(8)<<"千克"; outfile<<"保質(zhì)期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidFood::Save_file(ostream&Write_Food)//用于將Food商品信息保存到文件中{ Write_Food<<count<<endl; for(inti=0;i<count;i++) { Write_Food<<name[i]<<""<<number[i]<<""<<SaveTime[i]<<endl; }}voidElectricalAppliance::Input_file(ostream&outfile)//將ElectricalAppliance類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有家電類(ElectricalAppliance)商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) {outfile<<"【"<<i+1<<"】"<<"家電名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<number[i]<<setw(6)<<"臺(tái)";outfile<<"顏色:"<<color[i]<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidElectricalAppliance::Save_file(ostream&Write_ElectricalAppliance)//用于將ElectricalAppliance商品信息保存到文件中{ Write_ElectricalAppliance<<count<<endl; for(inti=0;i<count;i++) { Write_ElectricalAppliance<<name[i]<<""<<number[i]<<""<<color[i]<<endl; }}//Display函數(shù)voidSelectMenu()//實(shí)現(xiàn)商品操作的列表{ cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∵∴∵∴超市商品管理系統(tǒng)∵∴∵∴∵∴∵∴∵∴∵"<<endl<<endl; cout<<"\t可操作選項(xiàng):"<<endl<<endl; cout<<endl<<endl; cout<<"\t\t\t1增加商品"<<endl; cout<<"\t\t\t2出售商品"<<endl; cout<<"\t\t\t3查詢商品"<<endl; cout<<"\t\t\t"<<endl<<endl; cout<<"\t您要進(jìn)行的操作是:";}voidGoodList()//商品類別列表{ cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∴∵∵∴超市商品管理系統(tǒng)∵∴∵∴∵∴∵∴∵∴∵"<<endl<<endl; cout<<"\t我們提供的商品有:"<<endl; cout<<endl<<endl; cout<<"\t\t\t1日常用品類"<<endl; cout<<"\t\t\t2食品類"<<endl; cout<<"\t\t\t3家電類"<<endl; cout<<"\t\t"<<endl<<endl;}3詳細(xì)設(shè)計(jì)3.1系統(tǒng)總體設(shè)計(jì)一個(gè)簡(jiǎn)單的超市管理系統(tǒng)一個(gè)簡(jiǎn)單的超市管理系統(tǒng)增加商品出售商品查詢商品日常用品,食品,家電日常用品,食品,家電日常用品,食品,家電3.2源程序代碼//Supermarket.h#pragmaonce//保證頭文件只被編譯一次#include<iostream>usingnamespacestd;classSupermarket//要求(1)超市類,描述函數(shù)Add,Sale,Search{public: intAdd();//增加商品函數(shù),可以增加新商品,也可以增加已有商品 intSale();//按照商品名稱賣出商品函數(shù)(如果商品現(xiàn)有數(shù)量小于賣出數(shù)量,則不能繼續(xù)賣出,并給出提示信息) intSearch();//按照商品類別查詢商品情況的函數(shù),查詢結(jié)果:每類商品中有哪些商品,每種花商品的名稱和現(xiàn)有數(shù)量 intGood_num;};//Supermarket.cpp#pragmaonce#include"Goods.h"#include"Supermarket.h"#include"Display.h"usingnamespacestd;//增加商品的函數(shù)intSupermarket::Add(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您要增加什么類型的商品?"; cin>>Good_num; returnGood_num;}//按照商品名稱賣出商品的函數(shù)intSupermarket::Sale(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您要出售什么類型的商品?"; cin>>Good_num; returnGood_num;}//按照商品類別查詢商品情況的函數(shù)intSupermarket::Search(){ intGood_num; system("cls"); GoodList();//調(diào)用GoodList()函數(shù)語(yǔ)言 cout<<"\t\t您想要查詢什么類型的商品?"; cin>>Good_num; returnGood_num;}//Goods.h#pragmaonce#include<iostream>#include<string>#include<fstream>usingnamespacestd;//商品類GoodsclassGoods{public: virtualvoidAddGoods()=0;//增加商品 virtualvoidSaleGoods()=0;//出售商品 virtualvoidShowMe()=0;//顯示商品名稱、現(xiàn)有數(shù)量、和食品類的保質(zhì)期、以及家電的顏色 voidSale();//統(tǒng)一定義商品出售函數(shù)功能模塊protected: stringname[100];//記錄商品名稱 intnumber[100];//記錄商品數(shù)量 intcount;//記錄各類商品的各自的商品種數(shù)};//派生類:日常用品類DailyGoodsclassDailyGoods:publicGoods{public: DailyGoods();//無(wú)參構(gòu)造函數(shù) voidAddGoods();//增加商品 voidSaleGoods();//出售商品 friendistreamoperator>>(istream&in,DailyGoods&d); //對(duì)DailyGoods類重載運(yùn)算符>>,用于文件中讀取日常用品類的信息 voidShowMe();//顯示商品屬性 voidInput_file(ostream&outfile);//用于將商品信息輸出到文件中 voidSave_file(ostream&Write_DailyGoods);//用于將商品信息單獨(dú)保存到文件中};//派生類:食品類FoodclassFood:publicGoods{public: Food();//無(wú)參構(gòu)造函數(shù) voidAddGoods();//增加商品 voidSaleGoods();//出售商品 //friendistreamoperator>>(istream&in,Food&f); //對(duì)Food類重載運(yùn)算符>>,用于文件中讀取日常用品類的信息 voidShowMe();//顯示商品屬性 voidInput_file(ostream&outfile);//用于將商品信息輸出到文件中 voidSave_file(ostream&Write_Food);//用于將商品信息單獨(dú)保存到文件中private: intSaveTime[100];//保質(zhì)期};//派生類:家電類ElectricalApplianceclassElectricalAppliance:publicGoods{public: ElectricalAppliance();//無(wú)參構(gòu)造函數(shù) voidAddGoods();//增加商品 voidSaleGoods();//出售商品 //friendistreamoperator>>(istream&in,ElectricalAppliance&e); //對(duì)ElectricalAppliance類重載運(yùn)算符>>,用于文件中讀取日常用品類的信息 voidShowMe();//顯示商品屬性 voidInput_file(ostream&outfile);//用于將商品信息輸出到文件中 voidSave_file(ostream&Write_ElectricalAppliance);//用于將商品信息單獨(dú)保存到文件中private: stringcolor[100];//顏色屬性};//Goods.cpp#pragmaonce#include"Goods.h"#include"Supermarket.h"#include"Display.h"#include<fstream>#include<iomanip>usingnamespacestd;voidGoods::Sale()//統(tǒng)一定義商品出售函數(shù)功能模塊{ intflag=0; stringgoods_name; intgoods_number; cout<<"商品名稱:";cin>>goods_name;cout<<"出售數(shù)量:";cin>>goods_number; for(inti=0;i<count;i++)//count在Goods.h中定義的保護(hù)成員 { if(name[i]==goods_name) { if(number[i]<goods_number) { flag=1; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!貨存不足!!!"<<endl; } else { flag=1; number[i]-=goods_number; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!出售成功!!!"<<endl; } } } if(flag==0) { getchar(); cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t沒(méi)有該物品!"<<endl; }}//日常用品類函數(shù)定義DailyGoods::DailyGoods()//類外定義構(gòu)造函數(shù),初始化貨存日常用品信息{ count=4; name[0]="臺(tái)燈";number[0]=76; name[1]="毛巾";number[1]=68; name[2]="杯子";number[2]=53; name[3]="水壺";number[3]=48;}voidDailyGoods::AddGoods()//增加日常用品{ system("cls"); intflag=1; ShowMe(); cout<<endl<<"\t\t>>>>>>>>請(qǐng)輸入要增加日常用品的信息<<<<<<<<<"<<endl<<endl; cout<<"商品名稱:";cin>>name[count]; cout<<"商品數(shù)量:";cin>>number[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否已經(jīng)存在 { number[i]+=number[count]; flag=0; } } if(flag) count++;//用于新增物品 cout<<endl<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t!!!添加商品成功!!!"<<endl; cout<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl;}voidDailyGoods::SaleGoods(){ system("cls"); ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入要出售的日常用品信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale()函數(shù)}voidDailyGoods::ShowMe(){ cout<<endl<<"超市商品管理系統(tǒng)**日常用品區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有日常用品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"日常用品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"現(xiàn)存數(shù)量:"<<number[i]<<"個(gè)"<<endl; cout<<""<<endl; }}voidDailyGoods::Input_file(ostream&outfile)//將DailyGoods類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有日常用品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"日常用品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<number[i]<<"個(gè)"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidDailyGoods::Save_file(ostream&Write_DailyGoods)//用于將DailyGoods商品信息單獨(dú)保存到文件中{ Write_DailyGoods<<count<<endl; for(inti=0;i<count;i++) { Write_DailyGoods<<name[i]<<""<<number[i]<<endl; }}//食品類Food的函數(shù)定義Food::Food()//類外定義構(gòu)造函數(shù),初始化火車食品信息{ count=6; name[0]="蘋果";number[0]=360;SaveTime[0]=15; name[1]="香蕉";number[1]=500;SaveTime[1]=5; name[2]="李子";number[2]=450;SaveTime[2]=2; name[3]="西瓜";number[3]=350;SaveTime[3]=8; name[4]="楊梅";number[4]=400;SaveTime[4]=7; name[5]="芒果";number[5]=300;SaveTime[5]=21;}voidFood::AddGoods(){ system("cls"); intflag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入需要增加的食品信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl; cout<<"商品名稱:";cin>>name[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否存在 { number[i]+=number[count]; flag=0; } } if(flag) { cout<<"商品數(shù)量:";cin>>number[count]; cout<<"保質(zhì)期:";cin>>SaveTime[count]; count++;//用于新增物品 } cout<<endl<<endl<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl<<endl; cout<<"\t\t\t添加商品成功!!!"<<endl; cout<<endl<<endl<<endl<<endl; cout<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl<<endl;}voidFood::SaleGoods(){ system("cls"); ShowMe(); cout<<endl<<"~~~~~~~~~~~~~~~~~~~~~~~~請(qǐng)輸入要出售的食品信息~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale函數(shù)}voidFood::ShowMe(){ cout<<endl<<"超市商品管理系統(tǒng)**食品區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有食品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"食品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i];//執(zhí)行由有參數(shù)指定區(qū)域內(nèi)的動(dòng)作 cout<<"現(xiàn)存數(shù)量:"<<setw(4)<<number[i]<<setw(8)<<"千克";//setw(n)設(shè)域?qū)挒閚個(gè)字符 cout<<"保質(zhì)期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; cout<<""<<endl; }}voidFood::Input_file(ostream&outfile)//將Food類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有食品類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"食品名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<setw(4)<<number[i]<<setw(8)<<"千克"; outfile<<"保質(zhì)期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidFood::Save_file(ostream&Write_Food)//用于將Food商品信息保存到文件中{ Write_Food<<count<<endl; for(inti=0;i<count;i++) { Write_Food<<name[i]<<""<<number[i]<<""<<SaveTime[i]<<endl; }}//家電類(ElectricalAppliance)的函數(shù)定義ElectricalAppliance::ElectricalAppliance()//類外定義構(gòu)造函數(shù),初始化貨存家電信息{ count=3; name[0]="空調(diào)";number[0]=123;color[0]="黑色"; name[1]="冰箱";number[1]=111;color[1]="白色"; name[2]="電視";number[2]=104;color[2]="紅色"; name[3]="洗衣機(jī)";number[3]=125;color[3]="藍(lán)色";}voidElectricalAppliance::AddGoods()//增加家電{ system("cls"); intflag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯請(qǐng)輸入要增加的家電的信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; cout<<"商品名稱:";cin>>name[count]; for(inti=0;i<count;i++) { if(name[i]==name[count])//判斷該物品是否已經(jīng)存在 { cout<<"商品數(shù)量:"; cin>>number[count]; number[i]+=number[count]; flag=0; } } if(flag) { cout<<"商品數(shù)量:"; cin>>number[count]; cout<<"顏色:"; cin>>color[count]; count++;//用于新增物品 } cout<<endl<<endl<<"\t\t*************************************"<<endl; cout<<"\t\t!!!添加商品成功!!!!"<<endl; cout<<"\t\t*************************************"<<endl;}voidElectricalAppliance::SaleGoods(){ system("cls"); ShowMe(); cout<<endl<<">>>>>>>>請(qǐng)輸入要出售的家電信息>>>>>>>>"<<endl<<endl; Sale();//調(diào)用基類Goods里的Sale()函數(shù)}voidElectricalAppliance::ShowMe(){ cout<<endl<<"超市商品管理系統(tǒng)**家電區(qū)"<<endl<<endl; cout<<endl<<"現(xiàn)有家電類商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) { cout<<"【"<<i+1<<"】"<<"家電名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"現(xiàn)存數(shù)量:"<<number[i]<<setw(6)<<"臺(tái)"; cout<<"顏色:"<<color[i]<<endl; cout<<""<<endl; }}voidElectricalAppliance::Input_file(ostream&outfile)//將ElectricalAppliance類商品信息打印到文件中{ outfile<<endl<<"現(xiàn)有家電類(ElectricalAppliance)商品庫(kù)存:"<<endl<<endl; for(inti=0;i<count;i++) {outfile<<"【"<<i+1<<"】"<<"家電名稱:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"現(xiàn)存數(shù)量:"<<number[i]<<setw(6)<<"臺(tái)";outfile<<"顏色:"<<color[i]<<endl; } outfile<<endl<<endl<<endl<<endl<<endl;}voidElectricalAppliance::Save_file(ostream&Write_ElectricalAppliance)//用于將ElectricalAppliance商品信息保存到文件中{ Write_ElectricalAppliance<<count<<endl; for(inti=0;i<count;i++) { Write_ElectricalAppliance<<name[i]<<""<<number[i]<<""<<color[i]<<endl; }}//Display.h#pragmaonce#include<iostream>usingnamespacestd;voidLoading();//登入系統(tǒng)的頁(yè)面voidSelectMenu();//實(shí)現(xiàn)商品造作的列表voidGoodList();//商品類別列表voidEnd();//退出時(shí)的結(jié)束畫面//Display.cpp#pragmaonce#include"Goods.h"#include"Display.h"usingnamespacestd;voidLoading()//登陸系統(tǒng)時(shí)的界面{ system("cls"); cout<<endl<<endl<<endl<<endl<<endl<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆歡迎進(jìn)入超市商品管理系統(tǒng)☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<endl<<endl<<endl<<endl;}voidSelectMenu()//實(shí)現(xiàn)商品操作的列表{ cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∵∴∵∴超市商品管理系統(tǒng)∵∴∵∴∵∴∵∴∵∴∵"<<endl<<endl; cout<<"\t可操作選項(xiàng):"<<endl<<endl; cout<<endl<<endl; cout<<"\t\t\t1增加商品"<<endl; cout<<"\t\t\t2出售商品"<<endl; cout<<"\t\t\t3查詢商品"<<endl; cout<<"\t\t\t"<<endl<<endl; cout<<"\t您要進(jìn)行的操作是:";}voidGoodList()//商品類別列表{ cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∴∵∵∴超市商品管理系統(tǒng)∵∴∵∴∵∴∵∴∵∴∵"<<endl<<endl; cout<<"\t我們提供的商品有:"<<endl; cout<<endl<<endl; cout<<"\t\t\t1日常用品類"<<endl; cout<<"\t\t\t2食品類"<<endl; cout<<"\t\t\t3家電類"<<endl; cout<<"\t\t"<<endl<<endl;}voidEnd()//退出時(shí)的結(jié)束畫面{ system("cls"); cout<<endl<<endl<<endl<<endl<<endl<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆謝謝進(jìn)入超市商品管理系統(tǒng)☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆☆★☆"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<"\t☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"<<endl; cout<<endl<<endl<<endl<<endl;}//file.h#pragmaonce#include"Supermarket.h"#include"Goods.h"#include"Display.h"#include<conio.h>#include<stdlib.h>//用于控制運(yùn)行窗口屬性的必要頭文件#include<fstream>//文件操作#include<iomanip>usingnamespacestd;intscreen(){ DailyGoodsdailygoods; Foodfood; ElectricalApplianceelectricalappliance;/*創(chuàng)建文件,用于讀取與輸出信息*/ system("mdC:\\SuperMarket");//在(C:)盤新建一個(gè)SuperMarket文件夾 system("cls"); ofstreamoutfile("C:\\SuperMarket\\SuperMarket.txt",ios::out);//創(chuàng)建SuperMarket.doc文件,用于保存商品信息 ofstreamNew_DailyGoods("C:\\SuperMarket\\DailyGoods.dat",ios::out);//首先建立一個(gè)DailyGoods文件保存DailyGoods信息 fstreamWrite_DailyGoods("C:\\SuperMarket\\DailyGoods.dat",ios::in|ios::out);//實(shí)現(xiàn)對(duì)DailyGoods文件的可讀可寫 ofstreamNew_Food("C:\\SuperMarket\\Food.dat",ios::out);//首先建立一個(gè)Food文件保存Food信息 fstreamWrite_Food("C:\\SuperMarket\\Food.dat",ios::in|ios::out);//實(shí)現(xiàn)對(duì)Food文件的可讀可寫 ofstreamNew_ElectricalAppliance("C:\\SuperMarket\\ElectricalAppliance.dat",ios::out);//首先建立一個(gè)ElectricalAppliance文件保存ElectricalAppliance信息 fstreamWrite_ElectricalAppliance("C:\\SuperMarket\\ElectricalAppliance.dat",ios::in|ios::out);//實(shí)現(xiàn)對(duì)ElectricalAppliance文件的可讀可寫 //將庫(kù)存商品信息打印到“Supermarket.doc”文件中 outfile<<endl<<"超市商品管理系統(tǒng)"<<endl<<endl; outfile<<endl<<endl<<"\t\t\t∷∷∷∷∷∷∷∷∷∷∷∷"<<endl; dailygoods.Input_file(outfile);//將DailyGoods商品信息輸出到文件中 food.Input_file(outfile);//將Food商品信息輸出到文件中 electricalappliance.Input_file(outfile);//將ElectricalAppliance商品信息輸出到文件中 outfile<<"======================================================================="<<endl;//用于將各種商品的信息分類保存在文件中以便讀取 dailygoods.Save_file(Write_DailyGoods);//將DailyGoods商品信息單獨(dú)保存到文件中 food.Save_file(Write_Food);//將Food商品信息單獨(dú)保存到文件中 electricalappliance.Save_file(Write_ElectricalAppliance);//將ElectricalAppliance商品信息單獨(dú)保存到文件中//關(guān)閉文件指針 outfile.close(); Write_DailyGoods.close(); Write_Food.close(); Write_ElectricalAppliance.close(); return0;}//main.cpp#pragmaonce#include"Supermarket.h"#include"Goods.h"#include"Display.h"#include"file.h"#include<conio.h>usingnamespacestd;intmain(){ intchoice=1,t;//用于選擇菜單 intsign=1;//控制循
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2031年中國(guó)牙鉆車下部組件行業(yè)投資前景及策略咨詢研究報(bào)告
- 2025至2031年中國(guó)單滾筒式木材剝皮機(jī)行業(yè)投資前景及策略咨詢研究報(bào)告
- 2025至2030年中國(guó)釣魚眼鏡數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025至2030年中國(guó)迷你投影儀數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025至2030年中國(guó)壓膠條數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025至2030年中國(guó)醫(yī)用家具數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025年中國(guó)碧芽春茶市場(chǎng)調(diào)查研究報(bào)告
- 壓縮機(jī)在照明行業(yè)的氣體填充技術(shù)考核試卷
- 公共設(shè)施管理的績(jī)效評(píng)價(jià)考核試卷
- 健康心血管健康與血脂管理考核試卷
- 2025年個(gè)人學(xué)習(xí)領(lǐng)導(dǎo)講話心得體會(huì)和工作措施例文(6篇)
- 2025大連機(jī)場(chǎng)招聘109人易考易錯(cuò)模擬試題(共500題)試卷后附參考答案
- 2020-2025年中國(guó)中小企業(yè)行業(yè)市場(chǎng)調(diào)研分析及投資戰(zhàn)略咨詢報(bào)告
- 2025-2030年中國(guó)電動(dòng)高爾夫球車市場(chǎng)運(yùn)行狀況及未來(lái)發(fā)展趨勢(shì)分析報(bào)告
- 物流中心原材料入庫(kù)流程
- 河南省濮陽(yáng)市2024-2025學(xué)年高一上學(xué)期1月期末考試語(yǔ)文試題(含答案)
- 長(zhǎng)沙市2025屆中考生物押題試卷含解析
- 2024年08月北京中信銀行北京分行社會(huì)招考(826)筆試歷年參考題庫(kù)附帶答案詳解
- 2024年芽苗菜市場(chǎng)調(diào)查報(bào)告
- 蘇教版二年級(jí)數(shù)學(xué)下冊(cè)全冊(cè)教學(xué)設(shè)計(jì)
- 職業(yè)技術(shù)學(xué)院教學(xué)質(zhì)量監(jiān)控與評(píng)估處2025年教學(xué)質(zhì)量監(jiān)控督導(dǎo)工作計(jì)劃
評(píng)論
0/150
提交評(píng)論