收藏 分销(赏)

C专业课程设计小型超市标准管理系统.doc

上传人:快乐****生活 文档编号:2727361 上传时间:2024-06-05 格式:DOC 页数:50 大小:418.04KB 下载积分:14 金币
下载 相关 举报
C专业课程设计小型超市标准管理系统.doc_第1页
第1页 / 共50页
C专业课程设计小型超市标准管理系统.doc_第2页
第2页 / 共50页


点击查看更多>>
资源描述
江 苏 师 范 大 学 科 文 学 院 本 科 生 课 程 设 计 课 程 名 称: C++课程设计 题 目: 小型超市管理系统 专 业 班 级: 14电信1班 学 生 姓 名: 杨顺顺 学 生 学 号: 日 期: .12.10 指 导 教 师: 袁博宇 科文学院教务部印制 一、课程设计目标、任务和内容要求: 设计一个简单超市管理系统。 1.暂定有三个货架,分别放着日常见具、食品和家电。 2.能够实货架商品增加和出售。 3.设计查询功效,能够查找商品现实状况。 4.不一样商品有不一样属性:食品类,保质期,家电,颜色。 5.重载运算符>>。 设计要求: 要求利用面向对象方法和C++编程思想来完成系统设计; 要求在设计过程中,建立清楚类层次; 在系统设计中,最少要用到面向对象一个机制。 二、进度安排: 第1~3天: 查找资料,熟悉小型超市管理系统设计原理,给出设计总体方案; 第4~6天: 各函数具体设计; 第7~12天: 程序调试; 第13~14天:写课程设计汇报。 三、关键参考文件: 1.《c++语言程序设计(第四版)》——郑莉 董渊 何江舟 编著 指导老师签字: 年 月 日 目 录 摘 要·······································1 1概 述·······································2 2 设计方案简述·······························3 2.1 设计内容·································3 2.2 设计目标和要求···························3 2.3 系统分析和设计··························3 3 具体设计··································12 3.1 系统总体设计···························12 3.2 源程序代码·····························13 4 运行结果··································28 5设计体会··································32 摘 要  现代社会中伴伴随计算机技术在各行各业日益广泛和深入应用,超市对货物于职员管理不在像过去一样靠手工去做,在部分超市管理中也开始信息化。信息化管理能够为超市节省大量人力物力,提升其运行效率,从而为用户提供愈加好服务,实现超市业务提升。  本系统就是为了适应这种要求而设计。集信息显示、输入、修改、删除、查询等多种处理为一体,信息维护起来很方便。大大降低了超市人力和物力。  本系统大致要做到以下几点:  (1) 操作简便,节省大量人力;  (2) 能够方便进行货物管理,安全、高效;  (3) 能够快速计算销售额和所买卖货物;  (4) 能够快速查到所需信息,便于管理 1 概 述 1.1任务:  超市管理系统对职员商品信息进行高效简练管理,使之能正常高效进行售卖活动。系统充足考虑到超市管理系统对货物资料进行登记并处理。考虑到进货、退货、库存预警、年月日销售额结算等多个特殊情况,同时可将相关资料进行有效处理。 1.2目标:   现代社会中伴伴随计算机技术在各行各业日益广泛和深入应用,超市对货物于职员管理不在像过去一样靠手工去做,在部分超市管理中也开始信息化。信息化管理能够为超市节省大量人力物力,提升其运行效率,从而为用户提供愈加好服务,实现超市业务提升。  本系统就是为了适应这种要求而设计。集信息显示、输入、修改、删除、查询等多种处理为一体,信息维护起来很方便。大大降低了超市人力和物力。  本系统大致要做到以下几点:  (1) 操作简便,节省大量人力;  (2)能够方便进行货物管理,安全、高效;  (3) 能够快速计算销售额和所买卖货物;  (4) 能够快速查到所需信息,便于管理。 2.设计方案简述 2.1设计内容 设计一个简单超市管理系统。 1.暂定有三个货架,分别放着日常见具、食品和家电。 2.能够实货架商品增加和出售。 3.设计查询功效,能够查找商品现实状况。 4.不一样商品有不一样属性:食品类,保质期,家电,颜色。 5.重载运算符>>。 2.2设计目标和要求 2.2.1设计目标 达成熟练掌握C++语言基础知识和技能; 基础掌握面向对象程序设计基础思绪和方法; 能够利用所学基础知识和技能,处理简单面向对象程序设计问题。 2.2.2 设计要求 要求利用面向对象方法和C++编程思想来完成系统设计; 要求在设计过程中,建立清楚类层次; 在系统设计中,最少要用到面向对象一个机制。 2.3 系统分析和设计 2.3.1关键知识点 1)类,类内包含结构函数、组员函数、私有数据组员和一些输入输出函数; 2)运算符重载,定义一个重载运算符函数,在需要实施被重载运算符是,系统自动调用该函数; 3)继承和派生:1.基类即父类,被继承已经有类;2.派生类即子类,新建立类;3.这些类定义和申明同类; 4.虚函数作用是许可在派生类中重新定义和基类同名函数,而且能够经过基类指针或引用来访问基类和派生类中同名函数。 2.3.2关键技术 1)程序共有四个头文件和四个源文件。 头文件Supermarket,包含增加Add,出售Sale和查询Search三个公有组员函数; 源文件Supermarket,增加函数,出售函数和查询函数功效相同,选择功效,输出商品类型列表。 头文件Goods,在这个头文件中有四个类,一个基类和三个派生类。 基类Goods中设置增加AddGoods,出售SaleGoods,显示函数virtual ShowMe。同时定义统一出售函数Sale。保护组员包含,商品名称name[],商品数量number[]和商品分类数量count。 派生类,日常见具类DailyGoods,食物Food和家电ElectricalAppliance,除了本身无参结构函数,均从基类中继承增加AddGoods,出售SaleGoods,显示函数virtual ShowMe,并依据课题要求加入运算符重载函数istream operator >>(istream &in,DailyGoods &d)。同时借助函数Input_file和函数Save_file将商品信息输出并保留到文件中。 源文件Goods,实现各函数功效。 头文件diaplay,保留了小系统基础页面和选择页面。登录界面Loading,功效选择界面SelectMenu,商品功效列表GoodList和结束页面End。 源文件display,进行头文件各项函数功效实现。 头文件file,是相关文件存放,打开和关闭功效。 源文件main,实现功效汇总和实现方法。 2)部分函数实现 //Supermaket *Add函数 int Supermarket::Add() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您要增加什么类型商品?"; cin>>Good_num; return Good_num; } *Sale函数 int Supermarket::Sale() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您要出售什么类型商品?"; cin>>Good_num; return Good_num; } *Search函数 int Supermarket::Search() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您想要查询什么类型商品?"; cin>>Good_num; return Good_num; } //Goods *Sale函数 void Goods::Sale()//统一定义商品出售函数功效模块 { int flag=0; string goods_name; int goods_number; cout<<"商品名称:"; cin>>goods_name; cout<<"出售数量:"; cin>>goods_number; for(int i=0;i<count;i++) //count 在Goods.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 没有该物品! "<<endl; getchar(); } } *AddGoods函数 void DailyGoods::AddGoods()//增加日常见具 { system("cls"); int flag=1; ShowMe(); cout<<endl<<"\t\t>>>>>>>>请输入要增加日常见具信息<<<<<<<<<"<<endl<<endl; cout<<"商品名称:"; cin>>name[count]; cout<<"商品数量:"; cin>>number[count]; for(int i=0;i<count;i++) { if(name[i]==name[count])//判定该物品是否已经存在 { number[i]+=number[count]; flag=0; } } if(flag) count++;//用于新增物品 cout<<endl<<endl<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; cout<<"\t\t\t !!! 添加商品成功!!!"<<endl; cout<<"\t\t∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl; } void Food::AddGoods()//增加食品 { system("cls"); int flag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯请输入需要增加食品信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl; cout<<"商品名称:"; cin>>number[count]; for(int i=0;i<count;i++) { if(name[i]==name[count])//判定该物品是否存在 { number[i] += number[count]; flag=0; } } if(flag) { cout<<"商品数量:"; cin>>number[count]; cout<<"保质期:"; 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; } void ElectricalAppliance::AddGoods()//增加家电 { system("cls"); int flag=1; ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯请输入要增加家电信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; cout<<"商品名称:"; cin>>name[count]; for(int i=0;i<count;i++) { if(name[i]==name[count])//判定该物品是否已经存在 { cout<<"商品数量:"; cin>>number[count]; number[i]+=number[count]; flag=0; } } if(flag) { cout<<"商品数量:"; cin>>number[count]; cout<<"颜色:"; cin>>color[count]; count++;//用于新增物品 } cout<<endl<<endl<<"\t\t*************************************"<<endl; cout<<"\t\t !!! 添加商品成功!!!!"<<endl; cout<<"\t\t*************************************"<<endl; } *SaleGoods函数 void DailyGoods::SaleGoods()//出售日常见具 { system("cls"); ShowMe(); cout<<endl<<"≯≯≯≯≯≯≯≯≯≯≯≯≯≯≯请输入要出售日常见具信息≮≮≮≮≮≮≮≮≮≮≮≮≮≮≮"<<endl<<endl; Sale();//调用基类Goods里Sale()函数 } void Food::SaleGoods()//出售食品 { system("cls"); ShowMe(); cout<<endl<<"~~~~~~~~~~~~~~~~~~~~~~~~请输入要出售食品信息~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl; Sale(); //调用基类Goods里Sale函数 } void ElectricalAppliance::SaleGoods() //卖出家电 { system("cls"); ShowMe(); cout<<endl<<">>>>>>>>请输入要出售家电信息>>>>>>>>"<<endl<<endl; Sale();//调用基类Goods里Sale()函数 } *ShowMe函数 void DailyGoods::ShowMe() //显示日常见具 { cout<<endl<<" 超市商品管理系统**日常见具区 "<<endl<<endl; cout<<endl<<"现有日常见具类商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { cout<<" 【"<<i+1<<"】"<<"日常见具名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"现存数量:"<<number[i]<<"个"<<endl; cout<<" -----------------------------------------------"<<endl; } } void Food::ShowMe() //显示食品信息 { cout<<endl<<" 超市商品管理系统**食品区 "<<endl<<endl; cout<<endl<<"现有食品类商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { cout<<" 【"<<i+1<<"】"<<"食品名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; //实施由有参数指定区域内动作 cout<<"现存数量:"<<setw(4)<<number[i]<<setw(8)<<"千克"; // setw( n ) 设域宽为n个字符 cout<<"保质期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; cout<<" -----------------------------------------------------------"<<endl; } } void ElectricalAppliance::ShowMe() //显示家电信息 { cout<<endl<<" 超市商品管理系统**家电区 "<<endl<<endl; cout<<endl<<"现有家电类商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { cout<<" 【"<<i+1<<"】"<<"家电名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; cout<<"现存数量:"<<number[i]<<setw(6)<<"台"; cout<<"颜色:"<<color[i]<<endl; cout<<" ------------------------------------------------------------"<<endl; } } *文件输入和保留函数 void DailyGoods::Input_file(ostream&outfile)//将DailyGoods类商品信息打印到文件中 { outfile<<endl<<"现有日常见具类商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"日常见具名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"现存数量:"<<number[i]<<"个"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl; } void DailyGoods::Save_file(ostream&Write_DailyGoods)//用于将DailyGoods商品信息单独保留到文件中 { Write_DailyGoods<<count<<endl; for(int i=0;i<count;i++) { Write_DailyGoods<<name[i]<<" "<<number[i]<<endl; } } void Food::Input_file(ostream&outfile)//将Food类商品信息打印到文件中 { outfile<<endl<<"现有食品类商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"食品名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"现存数量:"<<setw(4)<<number[i]<<setw(8)<<"千克"; outfile<<"保质期:"<<setw(3)<<SaveTime[i]<<"天"<<endl; } outfile<<endl<<endl<<endl<<endl<<endl; } void Food::Save_file(ostream&Write_Food)//用于将Food商品信息保留到文件中 { Write_Food<<count<<endl; for(int i=0;i<count;i++) { Write_Food<<name[i]<<" "<<number[i]<<" "<<SaveTime[i]<<endl; } } void ElectricalAppliance:: Input_file(ostream&outfile)//将ElectricalAppliance类商品信息打印到文件中 { outfile<<endl<<"现有家电类(ElectricalAppliance)商品库存:"<<endl<<endl; for(int i=0;i<count;i++) { outfile<<"【"<<i+1<<"】"<<"家电名称:"<<setiosflags(ios::left)<<setw(15)<<name[i]; outfile<<"现存数量:"<<number[i]<<setw(6)<<"台"; outfile<<"颜色:"<<color[i]<<endl; } outfile<<endl<<endl<<endl<<endl<<endl; } void ElectricalAppliance::Save_file(ostream&Write_ElectricalAppliance)//用于将ElectricalAppliance商品信息保留到文件中 { Write_ElectricalAppliance<<count<<endl; for(int i=0;i<count;i++) { Write_ElectricalAppliance<<name[i]<<" "<<number[i]<<" "<<color[i]<<endl; } } //Display函数 void SelectMenu()//实现商品操作列表 { cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∵∴∵∴ 超 市 商 品 管 理 系 统∵∴∵∴∵∴∵∴∵∴∵ "<<endl<<endl; cout<<"\t 可操作选项:"<<endl<<endl; cout<<endl<<endl; cout<<"\t\t\t 1 增加商品"<<endl; cout<<"\t\t\t 2 出售商品"<<endl; cout<<"\t\t\t 3 查询商品"<<endl; cout<<"\t\t\t "<<endl<<endl; cout<<"\t您要进行操作是:"; } void GoodList()//商品类别列表 { cout<<endl<<"∴∵∴∵∴∵∴∵∴∵∴∴∵∵∴ 超 市 商 品 管 理 系 统∵∴∵∴∵∴∵∴∵∴∵"<<endl<<endl; cout<<"\t 我们提供商品有:"<<endl; cout<<endl<<endl; cout<<"\t\t\t 1 日常见具类"<<endl; cout<<"\t\t\t 2 食品类"<<endl; cout<<"\t\t\t 3 家电类"<<endl; cout<<"\t\t "<<endl<<endl; } 3 具体设计 3.1系统总体设计 一个简单超市管理系统 增加商品 出售商品 查询商品 日常见具,食品,家电 日常见具,食品,家电 日常见具,食品,家电 3.2源程序代码 //Supermarket.h #pragma once //确保头文件只被编译一次 #include<iostream> using namespace std; class Supermarket //要求(1)超市类,描述函数Add,Sale,Search { public: int Add(); //增加商品函数,能够增加新商品,也能够增加已经有商品 int Sale(); //根据商品名称卖出商品函数(假如商品现有数量小于卖出数量,则不能继续卖出,并给出提醒信息) int Search(); //根据商品类别查询商品情况函数,查询结果:每类商品中有哪些商品,每种花商品名称和现有数量 int Good_num; }; //Supermarket.cpp #pragma once #include"Goods.h" #include"Supermarket.h" #include"Display.h" using namespace std; //增加商品函数 int Supermarket::Add() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您要增加什么类型商品?"; cin>>Good_num; return Good_num; } //根据商品名称卖出商品函数 int Supermarket::Sale() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您要出售什么类型商品?"; cin>>Good_num; return Good_num; } //根据商品类别查询商品情况函数 int Supermarket::Search() { int Good_num; system("cls"); GoodList(); //调用GoodList()函数语言 cout<<"\t\t您想要查询什么类型商品?"; cin>>Good_num; return Good_num; } //Goods.h #pragma once #include<iostream> #include<string> #include<fstream> using namespace std; //商品类Goods class Goods { public: virtual void AddGoods()=0; //增加商品 virtual void SaleGoods()=0; //出售商品 virtual void ShowMe()=0; //显示商品名称、现有数量、和食品类保质期、和家电颜色 void Sale(); //统一定义商品出售函数功效模块 protected: string name[100]; //统计商品名称 int number[100]; //统计商品数量 int count; //统计各类商品各自商品种数 }; //派生类:日常见具类DailyGoods class DailyGoods:public Goods { public: DailyGoods(); //无参结构函数 void AddGoods(); //增加商品 void SaleGoods();//出售商品 friend istream operator >>(istream &in,DailyGoods &d); //对DailyGoods类重载运算符>>,用于文件中读取日常见具类信息 void ShowMe(); //显示商品属性 void Input_file(ostream&outfile); //用于将商品信息输出到文件中 void Save_file(ostream&Write_DailyGoods); //用于将商品信息单独保留到文件中 }; //派生类:食品类Food class Food:public Goods { public: Food(); //无参结构函数 void AddGoods(); //增加商品 void SaleGoods();//出售商品 //friend istream operator >>(istream &in,Food &f); //对Food类重载运算符>>,用于文件中读取日常见具类信息 void ShowMe(); //显示商品属性 void Input_file(ostream&outfile); //用于将商品信息输出到文件中 void Save_file(ostream&Write_Food); //用于将商品信息单独保留到文件中 private: int SaveTime[100]; //保质期 }; //派生类:家电类ElectricalAppliance class ElectricalAppliance:public Goods { public: ElectricalAppliance();//无参结构函数 void AddGoods(); //增加商品 void SaleGoods(); //出售商品 //friend istream operator >>(istream &in,ElectricalAppliance &e); //对ElectricalAppliance类重载运算符>>,用于文件中读取日常见具类信息 void ShowMe(); //显示商品属性 void Input_file(ostream&outfile); //用于将商品信息输出到文件中 void Save_file(ostream&Write_ElectricalAppliance); //用于将商品信息单独保留到文件中 private: string color[100]; //颜色属性 }; //Goods.cpp #pragma once #include"Goods.h" #include"Supermarket.h" #include"Display.h" #include<fstream> #include<iomanip> using namespace std; void Goods::Sale()//统一定义商品出售函数功效模块 { int flag=0; string goods_name; int goods_number; cout<<"商品名称:"; cin>>goods_name; cout<<"出售数量:"; cin>>goods_number; for(int i=0;i<count;i++) //count 在Goods.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 没有该物品! "<<endl; } } //日常见具类函数定义 DailyGoods::Da
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服