店铺管理模拟超市的收银系统.docx

上传人:b****4 文档编号:6921490 上传时间:2023-05-10 格式:DOCX 页数:10 大小:17.80KB
下载 相关 举报
店铺管理模拟超市的收银系统.docx_第1页
第1页 / 共10页
店铺管理模拟超市的收银系统.docx_第2页
第2页 / 共10页
店铺管理模拟超市的收银系统.docx_第3页
第3页 / 共10页
店铺管理模拟超市的收银系统.docx_第4页
第4页 / 共10页
店铺管理模拟超市的收银系统.docx_第5页
第5页 / 共10页
店铺管理模拟超市的收银系统.docx_第6页
第6页 / 共10页
店铺管理模拟超市的收银系统.docx_第7页
第7页 / 共10页
店铺管理模拟超市的收银系统.docx_第8页
第8页 / 共10页
店铺管理模拟超市的收银系统.docx_第9页
第9页 / 共10页
店铺管理模拟超市的收银系统.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

店铺管理模拟超市的收银系统.docx

《店铺管理模拟超市的收银系统.docx》由会员分享,可在线阅读,更多相关《店铺管理模拟超市的收银系统.docx(10页珍藏版)》请在冰点文库上搜索。

店铺管理模拟超市的收银系统.docx

店铺管理模拟超市的收银系统

 

(店铺管理)模拟超市的收银系统

模拟超市的收银系统

一、系统分析与设计。

随着计算机的发展,计算机技术已经融入到社会生活的各个角落,把人们从以前繁琐的手工操作中解放出来,从而使信息的管理大大简便起来。

超市日常有大量的数据需要进行处理,包括收银员收银时输入的消费者购买信息、管理员输入的入库商品信息、管理员输入的人员信息、日常销售额的统计等等。

面对如此大的信息量,就需要有相应的计算机管理系统来提高工作的效率和系统管理的安全性。

通过这样的系统,超市就可以由收银员方便的在收银柜台进行销售额的录入,管理员也可以方便地进行管理,从而减小手工操作的工作量,本

设计就是为了模拟超市的收银系统。

从需求分析的角度来看,这个超市管理系统的需求如下所示:

该系统的功能主要是模拟超市的收银的过程,所以不需要设计数据库,当进入

根据系统需求,这个版本的超市管理系统是一个简单的管理系统,三、主要程序清单(见附录)

//************************************************************************

//*main.cpp系统主文件

//************************************************************************#include"counter.h"

//创建一个商店CStore*PrepareStore(){

//创建一个空商店CStore*pStore=newCStore();

//为商店配货CGoods*pGoods=newCGoods(1,"西瓜",4.50);pStore->AddGoods(pGoods,1000);pGoods=newCGoods(2,"鸡蛋",5.00);

pStore->AddGoods(pGoods,1000);pGoods=newCGoods(3,"牛肉",12.00);pStore->AddGoods(pGoods,1000);pGoods=newCGoods(4,"香蕉",4.10);pStore->AddGoods(pGoods,1000);

pGoods=newCGoods(5,"空调",3000.00);pStore->AddGoods(pGoods,100);pGoods=newCGoods(6,"大米",1.00);pStore->AddGoods(pGoods,10000);pGoods=newCGoods(7,"葡萄",5.00);pStore->AddGoods(pGoods,1000);pGoods=newCGoods(8,"面包",6.00);pStore->AddGoods(pGoods,1000);pGoods=newCGoods(9,"火腿",15.00);pStore->AddGoods(pGoods,1000);returnpStore;

}

voidusage(){cout<<"\n\n";cout.width(35);cout.fill('*');cout<

cout<<"*请您按照请示来购买商品,祝您消费愉快!

\n";cout<<"*输入\"-1\",完成购买,去收银台\n";cout.width(35);

cout.fill('*');cout<

}

voidmain()

{

//准备超市储藏室、购物篮、收银台CStore*pStore=PrepareStore();//给超市配货CStore*pBasket=newCStore();

CCounterCounter(pBasket);doubledCash=0.0;

cout<<"------------------------欢迎光临\"美特好\"超市

------------------------\n\n"<

cout<<"*******************本超市共有以下商品,欢迎您的选购

*******************"<

//打印商店的现有商品pStore->Print();usage();

//iIndex---用户欲购买商品的索引,iNum用户欲购买商品的数目

intiIndex=0,iNum=0;do{

cout<<"请输入商品索引号:

";

//非法输入if(!

(cin>>iIndex)){

cout<<"\n\n你键入了非法的索引号,程序即将退出\n\n";gotoCELEAN;

}

//购买完毕,退出if(iIndex==-1){break;

}

//获取iIndex所对应的商品PSTOREELEMENTpSE=pStore->GetGoods(iIndex);

//没有此类商品if(pSE==NULL){

cout<<"\n很抱歉,本商店没有索引号为\""<

}

//购买数量

cout<<"请输入要购买数量:

";

//非法输入if(!

(cin>>iNum)){

cout<<"\n\n你键入了非法的购买数目,程序即将退出\n\n";

gotoCELEAN;

}

//商品查询

intiStoreNum=pStore->QueryGoods(iIndex);if(iStoreNum<=0){

cout<<"很抱歉,你要购买的\""<pGoods->GetName()<<"\"商品已经售完,请下次再来购买!

\n";

}

else{if(iNum>iStoreNum){

cout<<"很抱歉,本商店目前仅有\""<pGoods->GetName()<<"\""<

CGoods*pMyGoods=pSE->pGoods->Clone();

pBasket->AddGoods(pMyGoods,iStoreNum);//加入购物篮pSE->iNum=0;//卖光了

}

else{

cout<<"恭喜你,成功购买:

\n";

cout<<"商品:

"<pGoods->GetName()<<"件数:

"<pGoods->Clone();

pBasket->AddGoods(pMyGoods,iNum);//加入购物篮pSE->iNum=iStoreNum-iNum;//超市剩余

}

}

}while(true);

if(pBasket->GetAllGoods()->size()==0){cout<<"\n\n嗨,什么都没买到,白来一趟;(\n\n";gotoCELEAN;

}

else{

cout<<"\n\n购买完毕,今天收获不小啊,购买了如下商品:

\n\n";pBasket->Print();

}

cout<<"\n\n您好,您本次共计消费"<

cout<<"请交钱:

";cin>>dCash;

while(Counter.Count(dCash)<0){

cout<<"还差:

"<<-Counter.Count(0)<<"元\n";cout<<"请交钱:

";

cin>>dCash;

}

cout<<"\n\n共收取您现金:

"<

"<

cout<<"应找零:

"<

deletepStore;deletepBasket;return;

//counter.cpp:

implementationofthesupermarketclass.

//

//////////////////////////////////////////////////////////////////////#include"counter.h"

#include

//************************************************************************

//*商品类的成员函数定义

//************************************************************************CGoods:

:

CGoods(intiIndex,stringstrName,doubledUnitPrice)

{

//初始化商品m_iIndex=iIndex;m_strName=strName;m_dUnitPrice=dUnitPrice;

}

CGoods:

:

~CGoods()

{

}

//attributesandoperations

intCGoods:

:

GetIndex(void)const{returnm_iIndex;

}

stringCGoods:

:

GetName(void)const{returnm_strName;

}

doubleCGoods:

:

GetUnitPrice(void)const{returnm_dUnitPrice;

}

voidCGoods:

:

SetUnitPrice(doubledUnitPrice){m_dUnitPrice=dUnitPrice;

}

CGoods*CGoods:

:

Clone(){returnnewCGoods(m_iIndex,m_strName,m_dUnitPrice);

}

//************************************************************************

//*商品类的成员函数定义结束

//************************************************************************

//************************************************************************

//*储藏室类的成员函数定义

//************************************************************************CStore:

:

CStore()

{

}

CStore:

:

~CStore()

{

DeleteAllGoods();

}

//往储藏室种添加货物boolCStore:

:

AddGoods(CGoods*pGoods,intiNum){assert(pGoods!

=NULL);intsize=m_vStore.size();

boolbIsExist=false;for(inti=0;i

PSTOREELEMENTpSE=m_vStore[i];assert(pSE!

=NULL);

//假如已经有了同类商品在储藏室,那么增加此商品的数目

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetIndex()==pGoods->GetIndex()){bIsExist=true;

pSE->iNum+=iNum;break;

}

}

//储藏室没有同类商品,直接增加此类商品if(!

bIsExist){PSTOREELEMENTp=newSTOREELEMENT;

p->pGoods=pGoods;p->iNum=iNum;

m_vStore.push_back(p);

}

returntrue;

}

//清空整个储藏室voidCStore:

:

DeleteAllGoods(){intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL){deletepSE->pGoods;//删除商品pSE->pGoods=NULL;

}

deletepSE;//删除储藏室元素pSE=NULL;

}

}

//删除名为strName的货物,iNum为删除数量intCStore:

:

DeleteGoods(conststring&strName,intiNum){

intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetName()==strName){if(iNum<=-1||pSE->iNum<=iNum){

deletepSE->pGoods;pSE->iNum=0;

deletepSE;//删除储藏室元素pSE=NULL;

return0;

}

else{

pSE->iNum-=iNum;returnpSE->iNum;

}

}

}

return0;

}

//删除索引号为iIndex的货物,iNum为删除数量intCStore:

:

DeleteGoods(intiIndex,intiNum){intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetIndex()==iIndex){if(iNum<=-1||pSE->iNum<=iNum){

deletepSE->pGoods;pSE->iNum=0;

deletepSE;//删除储藏室元素pSE=NULL;

return0;

}

else{

pSE->iNum-=iNum;returnpSE->iNum;

}

}

}

return0;

}

//获取货物清单vector*CStore:

:

GetAllGoods(void){return&m_vStore;

}

//获取某类货物PSTOREELEMENTCStore:

:

GetGoods(intiIndex){intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetIndex()==iIndex){returnpSE;

}

}

returnNULL;

}

//获取某类货物PSTOREELEMENTCStore:

:

GetGoods(conststring&strName){intsize=m_vStore.size();

for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetName()==strName){returnpSE;

}

}

returnNULL;

}

//查询货物intCStore:

:

QueryGoods(conststring&strName){intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetName()==strName){returnpSE->iNum;

}

}

return0;

}

//查询货物intCStore:

:

QueryGoods(intiIndex){intsize=m_vStore.size();for(inti=0;i

=NULL);

if(pSE->pGoods!

=NULL&&pSE->pGoods->GetIndex()==iIndex){returnpSE->iNum;

}

}

return0;

}

//打印水单voidCStore:

:

Print(){stringstrTitle[4];strTitle[0]="索引号";strTitle[1]="商品名";strTitle[2]="数量";strTitle[3]="单价";for(inti=0;i<4;i++){

cout.width(16);cout<

}

cout<<"\n"<

//获取商品种类intsize=m_vStore.size();for(i=0;i

cout<pGoods->GetIndex();cout.width(16);

cout<pGoods->GetName();cout.width(16);

cout<iNum;cout.width(16);cout.precision

(2);

cout<pGoods->GetUnitPrice()<<"\n";

}

}

//************************************************************************

//*储藏室类的成员函数定义结束

//************************************************************************

//************************************************************************

//*收银台类的成员函数定义

//************************************************************************CCounter:

:

CCounter(CStore*pBasket)

{

m_pBasket=pBasket;m_dCash=0.0;

}

CCounter:

:

~CCounter()

{

}

//获取帐单doubleCCounter:

:

Bill(void){

doubledTotalPrice=0.0;vector*pvSE=m_pBasket->GetAllGoods();

//获取商品种类intsize=pvSE->size();for(inti=0;i

PSTOREELEMENTpSE=(*pvSE)[i];

dTotalPrice+=pSE->pGoods->GetUnitPrice()*pSE->iNum;

}

returndTotalPrice;

}

//收钱及找零doubleCCounter:

:

Count(doubledCash){m_dCash+=dCash;doubledTotal=Bill();

returnm_dCash-dTotal;

}

//收取的现金数doubleCCounter:

:

GetCash(){returnm_dCash;

}

//************************************************************************

//*收银台类的成员函数定义结束

//************************************************************************

}四、运行结果五、试验体会

在这次的设计过程中,我采用的是VC++,不仅使我对课程有了进一步的强化,还使我的开发能力得到了提高。

在此感谢给予我帮助的老师和同学们。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2