




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、-1-模擬超市的收銀系統(tǒng)一、系統(tǒng)分析與設(shè)計(jì)。隨著計(jì)算機(jī)的發(fā)展, 計(jì)算機(jī)技術(shù)已經(jīng)融入到社會(huì)生活的各個(gè)角落, 把人們從以前繁瑣的 手工操作中解放出來(lái), 從而使信息的管理大大簡(jiǎn)便起來(lái)。 超市日常有大量的數(shù)據(jù)需要進(jìn)行處 理,包括收銀員收銀時(shí)輸入的消費(fèi)者購(gòu)買(mǎi)信息、 管理員輸入的入庫(kù)商品信息、 管理員輸入的 人員信息、 日常銷售額的統(tǒng)計(jì)等等。 面對(duì)如此大的信息量, 就需要有相應(yīng)的計(jì)算機(jī)管理系統(tǒng) 來(lái)提高工作的效率和系統(tǒng)管理的安全性。 通過(guò)這樣的系統(tǒng), 超市就可以由收銀員方便的在收 銀柜臺(tái)進(jìn)行銷售額的錄入, 管理員也可以方便地進(jìn)行管理, 從而減小手工操作的工作量, 本 設(shè)計(jì)就是為了模擬超市的收銀系統(tǒng)。從需求分
2、析的角度來(lái)看,這個(gè)超市管理系統(tǒng)的需求如下所示:該系統(tǒng)的功能主要是模擬超市的收銀的過(guò)程, 所以不需要設(shè)計(jì)數(shù)據(jù)庫(kù), 當(dāng)進(jìn)入 系統(tǒng),就會(huì)顯示倉(cāng)庫(kù)里的所有貨物,當(dāng)管理員輸入貨物編號(hào)(索引號(hào))時(shí),就會(huì)提示 你需要買(mǎi)的數(shù)量,輸入完成就會(huì)提示你購(gòu)買(mǎi)成功。再就是付款。根據(jù)系統(tǒng)需求,這個(gè)版本的超市管理系統(tǒng)是一個(gè)簡(jiǎn)單的管理系統(tǒng), 三、主要程序清單(見(jiàn)附錄)/* /*main.cpp系統(tǒng)主文件*#include counter.h/創(chuàng)建一個(gè)商店CStore* PrepareStore()/創(chuàng)建一個(gè)空商店CStore *pStore = new CStore();/為商店配貨CGoods *pGoods = new
3、CGoods(1, 西瓜, 4.50); pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(2, 雞蛋, 5.00); pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(3, 牛肉, 12.00); pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(4, 香蕉, 4.10);pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(5, 空調(diào), 3000.00); pStore-AddGoods(pGoo
4、ds, 100);pGoods = new CGoods(6, 大米, 1.00); pStore-AddGoods(pGoods, 10000);-2-pGoods = new CGoods(7, 葡萄, 5.00); pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(8, 面包, 6.00); pStore-AddGoods(pGoods, 1000);pGoods = new CGoods(9, 火腿, 15.00); pStore-AddGoods(pGoods, 1000);return pStore;void usage() cou
5、tnn; cout.width(35); cout.fill(*); coutrightUSAGE; cout.width(35);coutleft*endl; cout*請(qǐng)您按照請(qǐng)示來(lái)購(gòu)買(mǎi)商品,祝您消費(fèi)愉快!n; cout*輸入-1,完成購(gòu)買(mǎi),去收銀臺(tái)n; cout.width(35); cout.fill(*); coutrightUSAGE;cout.width(35); coutleft*endl;cout.fill( ); coutPrint();usage();/ iIndex-用戶欲購(gòu)買(mǎi)商品的索引, iNum-用戶欲購(gòu)買(mǎi)商品的數(shù)目int iIndex = 0, iNum = 0;
6、do coutiIndex) ) coutGetGoods( iIndex );/沒(méi)有此類商品if (pSE = NULL) coutn很抱歉,本商店沒(méi)有索引號(hào)為iIndex的商品nn; continue;/購(gòu)買(mǎi)數(shù)量cout請(qǐng)輸入要購(gòu)買(mǎi)數(shù)量:;cout-歡迎光臨美特好超市cout*本超市共有以下商品,歡-nnendl;迎您的選購(gòu)*iNum) ) coutQueryGoods( iIndex );if (iStoreNum = 0) cout很抱歉,你要購(gòu)買(mǎi)的pGoods-GetName() iStoreNum ) cout很 抱 歉,本 商 店 目 前 僅 有pGoods-GetName()i
7、StoreNumpGoods-Clone();pBasket-AddGoods( pMyGoods, iStoreNum ); /加入購(gòu)物籃pSE-iNum = 0; /賣光了elsecout恭喜你,成功購(gòu)買(mǎi):n;cout商 品: pGoods-GetName()件 數(shù):iNumnpGoods-Clone();pBasket-AddGoods( pMyGoods, iNum );/加入購(gòu)物籃pSE-iNum= iStoreNum - iNum;/超市剩余-5- while(true);if (pBasket-GetAllGoods()-size() = 0) coutnn嗨,什么都沒(méi)買(mǎi)到,白來(lái)
8、一趟;(nn;goto CELEAN;else coutPrint();coutnn您好,您本次共計(jì)消費(fèi)Counter.Bill()元n; coutdCash;while ( Counter.Count(dCash) 0 ) cout 還差: -Counter.Count(0) 元n; cout dCash;coutnn共收取您現(xiàn)金:Counter.GetCash()元n; cout應(yīng)交納金額:Counter.Bill()元n;cout應(yīng)找零:Counter.Count(0)元nn;/*商品類的成員函數(shù)定義/*CGoods:CGoods( int iIndex, string strName,
9、 double dUnitPrice )cout*歡迎您再次光臨本店CELEAN:delete pStore;delete pBasket; return;/ counter.cpp: implementation of the supermarket class./#include counter.h#include *-6-/初始化商品m_iIndex = iIndex; m_strName = strName; m_dUnitPrice = dUnitPrice;CGoods:CGoods()/attributes and operationsint CGoods:GetIndex(vo
10、id) const return m_iIndex;string CGoods:GetName(void) constreturn m_strName;double CGoods:GetUnitPrice(void) const return m_dUnitPrice;void CGoods:SetUnitPrice(double dUnitPrice) m_dUnitPrice = dUnitPrice;CGoods *CGoods:Clone()return new CGoods(m_iIndex, m_strName, m_dUnitPrice);/*/*商品類的成員函數(shù)定義結(jié)束/*/*
11、/*儲(chǔ)藏室類的成員函數(shù)定義/*CStore:CStore()-7-CStore:CStore()DeleteAllGoods();/往儲(chǔ)藏室種添加貨物bool CStore:AddGoods(CGoods *pGoods, int iNum)assert( pGoods != NULL );int size = m_vStore.size();bool bIsExist = false;for(int i=0; ipGoods != NULL & pSE-pGoods-GetIndex() pGoods-GetIndex() ) bIsExist = true;pSE-iNum +=
12、iNum ;break;/儲(chǔ)藏室沒(méi)有同類商品,直接增加此類商品if ( !bIsExist )PSTOREELEMENT p = new STOREELEMENT; p-pGoods= pGoods;p-iNum= iNum;m_vStore.push_back( p );return true;/清空整個(gè)儲(chǔ)藏室void CStore:DeleteAllGoods()int size = m_vStore.size();for(int i=0; ipGoods != NULL )delete pSE-pGoods;/刪除商品-8-pSE-pGoods = NULL;delete pSE;/刪除
13、儲(chǔ)藏室元素pSE = NULL;/刪除名為strName的貨物,iNum為刪除數(shù)量int CStore:DeleteGoods(const string &strName, intiNum)int size = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetName() = strName )if ( iNum iNum pGoods; pSE-iNum =0;delete pSE;/刪除儲(chǔ)藏室元素pSE = NULL;return 0;elsepSE-iNum -= iNum; return pSE-
14、iNum;return 0;/刪除索引號(hào)為iIndex的貨物,iNum為刪除數(shù)量int CStore:DeleteGoods(int iIndex, intiNum)int size = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetIndex() = iIndex ) if ( iNum iNum pGoods; pSE-iNum = 0;delete pSE;/刪除儲(chǔ)藏室元素pSE = NULL;return 0;elsepSE-iNum -= iNum;return pSE-iNum;-10-return
15、 0;/獲取貨物清單vector* CStore:GetAllGoods(void)return &m_vStore;/獲取某類貨物PSTOREELEMENT CStore:GetGoods(int iIndex)int size = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetIndex() = iIndex ) return pSE;return NULL;/獲取某類貨物PSTOREELEMENT CStore:GetGoods(const string &strName)int size
16、 = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetName() = strName ) returnpSE;-11-return NULL;/查詢貨物int CStore:QueryGoods(const string &strName)int size = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetName() = strName ) returnpSE-iNum;return 0;/查詢貨物int CStore
17、:QueryGoods(int iIndex)int size = m_vStore.size();for(int i=0; ipGoods != NULL & pSE-pGoods-GetIndex() = iIndex ) returnpSE-iNum;return 0;/打印水單void CStore:Print() string strTitle4; strTitle0 = 索引號(hào); strTitle1 = 商品名;strTitle2 = 數(shù)量;strTitle3 = 單價(jià);for (int i=0; i4; i+) cout.width(16); coutleftstrTit
18、lei;-12-coutnendl;/獲取商品種類int size = m_vStore.size();for (i=0; isize; i+)cout.width(16); coutleftpGoods-GetIndex();cout.width(16);coutpGoods-GetName();cout.width(16);coutiNum;cout.width(16);cout.precision(2);coutfixedpGoods-GetUnitPrice()n;/*/*儲(chǔ)藏室類的成員函數(shù)定義結(jié)束/*/*/*收銀臺(tái)類的成員函數(shù)定義/*CCounter:CCounter(CStore *pBasket)m_pBasket = pBasket;m_dCash= 0.0;CCounter:CCounter()/獲取帳單double CCounter:Bill(void)dou
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司更換勞動(dòng)合同范例
- 人工合同范例
- 付國(guó)外傭金合同范例
- 民國(guó)歷史考試試題及答案
- 電商客服考試試題及答案
- 買(mǎi)賣塑鋼合同范例
- 2025簽訂股權(quán)轉(zhuǎn)讓合同應(yīng)注意的關(guān)鍵事項(xiàng)
- 數(shù)控鉆床考試試題及答案
- 營(yíng)養(yǎng)初級(jí)考試試題及答案
- 北京地鐵站務(wù)員考試試題及答案
- 《水滸傳》讀書(shū)匯報(bào)課
- 梅毒與hiv職業(yè)暴露及防護(hù)-圖文
- 鯉科魚(yú)類八亞科檢索表(新)
- 烙鐵頭的壽命一般有多長(zhǎng)
- GB∕T 37370-2019 中國(guó)常見(jiàn)色色名和色度特性
- 冀教英語(yǔ)六年級(jí)下冊(cè)作文范文
- Continual Improvement持續(xù)改進(jìn)程序(中英文)
- 10x2000對(duì)稱式三輥卷板機(jī)設(shè)計(jì)機(jī)械畢業(yè)設(shè)計(jì)論文
- RCA應(yīng)用于給藥錯(cuò)誤事情的分析結(jié)果匯報(bào)
- 申論答題紙-方格紙模板A4-可打印
- 土石方測(cè)量方案完整版
評(píng)論
0/150
提交評(píng)論