收藏 分销(赏)

C专业课程设计自助点餐系统.docx

上传人:快乐****生活 文档编号:2656297 上传时间:2024-06-03 格式:DOCX 页数:43 大小:915.76KB 下载积分:12 金币
下载 相关 举报
C专业课程设计自助点餐系统.docx_第1页
第1页 / 共43页
C专业课程设计自助点餐系统.docx_第2页
第2页 / 共43页


点击查看更多>>
资源描述
面向对象程序课程设计 (/第一学期第20周) 指导老师: 庄巧莉、杨东鹤 班级:计算机科学和技术13(1) 学号:你好你好你 姓名:你好你啊哈啊啊啊 面向对象程序课程设计 目 录 一、 题目 二、 需求分析 三、 系统结构图 四、 类设计 五、 程序代码和说明 六、 运行结果和分析 七、 心得和体会 一:题目 自助点餐系统 二:需求分析 有一个小型餐厅,该餐厅提供即时就餐和外卖服务。现在这个餐厅计划使用自助点餐系统,让用户自己点餐,实现以下功效。 1、依据用户选择正确打出账单 2、正确统计出每一天立即就餐和外卖销售情况 3、实现对餐厅菜式和价格有效管理 4、考虑点餐自动排序问题,使用户能够实时查询到自己菜单处理情况 三:系统结构图 四:类设计 Client类:用户类,包含用户属性姓名,电话号码,费用等信息,登记用户,统计用户订单信息 ClientManager类:用户管理类,用于管理用户,统计用户数量,存放用户菜单信息,查询用户订单信息,统计订单 FeeManager类:用于统计就餐、外卖销售费用,统计收入 Food类:餐厅食物类,包含食物名称和价格 FoodManager类:管理菜单,用于添加食物,修改食物,删除食物,统计不一样食物信息,展现菜单 MenuView类:用于打印多种操作界面 五:程序代码和说明 Client.h #ifndef CLIENT #define CLIENT #include"FoodManager.h" #include<iostream> using namespace std; class Client { private: int number; //用户编号 int type; //用户类型,1表示就餐,2表示外卖 double fee; //用户账单费用 char *name; //用户名称 char *phone; //用户手机号码 public: Client(){} //结构函数 char * getName(); //返回用户姓名 int num[100]; //num[i]存放食物数量,i表示食物编号 FoodManager client_fm; //管理用户所点食物 Client(char *n,char *p);//结构函数 int getNumber(); //返回用户编号 void setNumber(int n); //设置用户编号 int getType(); //返回用户类型 void setType(int n); //设置用户类型 void addFee(double x); //添加费用 double getFee(); //返回费用 void showClientMessage();//展示用户信息 void changNum(); //修改用户所点食物数量 void deleFood(); //删除用户所选择食物 }; #endif Client.cpp #include"Client.h" #include<iomanip> Client::Client(char *s,char *p) { name = s; phone = p; fee = 0; for(int i = 0 ; i < 100 ; i++) num[i] = 0 ; cout<<"用户注册成功"<<endl; } int Client::getNumber() { return number; } void Client::setNumber(int n) { number = n; } int Client::getType() { return type; } void Client::setType(int n) { type = n; } void Client::addFee(double x) { fee += x; } double Client::getFee() { return fee; } void Client::showClientMessage() { char * ss; if(type == 1)ss = "就餐"; else if(type == 2)ss = "外卖"; cout<<"姓名: "<<name<<"\t\t"<<ss<<endl; cout<<"手机号码: "<<phone<<endl; cout<<"订单总价: "<<fee<<endl; cout<<"订单详情:"<<endl; cout<<setw(10)<<setiosflags(ios::left)<<"食物序列"<<setw(10)<<setiosflags(ios::left)<<"菜名"<<"\t数量\t价格"<<endl; for(int i = 0 ; i < client_fm.getTotal() ; i ++) { cout<<setw(10)<<setiosflags(ios::left)<<setw(10)<<i+1<<setiosflags(ios::left)<<client_fm.food[i].getName()<<"\t"<<num[i]<<"\t"<<num[i]*client_fm.food[i].getPrice()<<endl; } cout<<"总价:\t\t"<<fee<<endl; } char * Client::getName() { return name; } void Client::changNum() { int n; int numss; cout<<"请输入食物序号: ";cin>>n; cout<<"您选择了食物: "<<client_fm.getNameByList(n-1)<<endl; cout<<"请输入数量: ";cin>>numss; fee += (numss - num[n-1] )*client_fm.getPriceByName(client_fm.getNameByList(n-1)); num[n-1]=numss; } void Client::deleFood() { int n; cout<<"请输入食物序号: ";cin>>n; cout<<"您选择了食物: "<<client_fm.getNameByList(n-1)<<endl; fee -= (num[n-1] )*client_fm.getPriceByName(client_fm.getNameByList(n-1)); for(int i = n-1 ; i < client_fm.getTotal() ; i ++) { client_fm.food[i]=client_fm.food[i+1]; num[i]=num[i+1]; } client_fm.setTotal(client_fm.getTotal()-1); } ClientManager.h #ifndef CLIENTMANAGER #define CLIENTMANAGER #include"Client.h" #include<iostream> using namespace std; #define MAX_CLIENT_NUM 60 //最大用户数量 class ClientManager { public: ClientManager(); //结构函数 int clientNum ; //统计用户数量 Client client[MAX_CLIENT_NUM]; //统计存放用户 void addClient(Client c); //添加新用户 int getClientNum(); //返回用户数量 void showQuery(char * s); //查询用户 void showAll(); //显示全部用户 }; #endif ClientManager.cpp #include"ClientManager.h" ClientManager::ClientManager() { clientNum = 0; } void ClientManager::addClient(Client c) { client[clientNum++] = c; cout<<"用户注册成功"<<endl; } int ClientManager::getClientNum() { return clientNum; } void ClientManager::showQuery(char * s) { int count = 0; int th; cout<<"----------------------------------"<<endl; for(int i = 0; i < clientNum ; i ++) if(client[i].getType()==1) { cout<<"第"<<++count<<"单: "<<client[i].getName()<<"\t总价是: "<<client[i].getFee()<<"元"<<"\t就餐"<<endl<<endl; if(strcmp(client[i].getName(),s)==0)th =count; } for(int i = 0; i < clientNum ; i ++) if(client[i].getType()==2) { cout<<"第"<<++count<<"单: "<<client[i].getName()<<"\t总价是: "<<client[i].getFee()<<"元"<<"\t外卖"<<endl<<endl; if(strcmp(client[i].getName(),s)==0)th =count; } cout<<"您目前排在第"<<th<<"单"<<endl; cout<<"----------------------------------"<<endl; } void ClientManager::showAll() { for(int i = 0 ; i < clientNum ; i ++ ) { if(client[i].getType()==1) { cout<<"订单号: "<<i+1<<endl; client[i].showClientMessage(); cout<<endl; } } for(int i = 0 ; i < clientNum ; i ++ ) { if(client[i].getType()==2) { cout<<"订单号: "<<i+1<<endl; client[i].showClientMessage(); cout<<endl; } } } Food.h #ifndef FOOD #define FOOD class Food { private: char *name; //食物名称 double price; //食物价格 public: Food(){}; //结构函数 Food(char *s,double p); //结构函数 void setName(char *s); //更改食物名称 char* getName(); //返回食物名称 double getPrice(); //返回食物价格 void setPrice(double p); //设置食物价格 void showMessage(); //显示食物名称和价格 }; #endif Food.cpp #include"Food.h" #include<iostream> using namespace std; Food::Food(char *s,double p) { name = s; price = p; } void Food::setName(char *s) { name = s; } void Food::setPrice(double p) { price = p; } void Food::showMessage() { cout<<name<<"\t"<<price<<"Ԫ"<<endl; } double Food::getPrice() { return price; } char* Food::getName() { return name; } FoodManager.h #ifndef FOODMANAGER #define FOODMANAGER #include"Food.h" #define MAX_FOOD_NUM 99 //最多容纳食物种类数 class FoodManager { int total ; //食物种类数 public: FoodManager(); //结构函数 int getTotal() ; //返回食物种类数 Food food[MAX_FOOD_NUM]; //统计食物 void addFood(Food f); //添加食物 void addFood(char *s,double p); //添加食物 void deleteFood(); //删除食物 void changePrice(); //修改食物价格 void showFood(); //显示食物信息 char * getNameByList(int list); //经过食物编号返回食物名称 double getPriceByName(char *s); //经过食物名称返回食物价格 int getListByName(char *s); //经过食物名称返回食物编号 void setTotal(int x); //修改食物种类数 }; #endif FoodManager.cpp #include"FoodManager.h" #include<iostream> using namespace std; #include<iomanip> FoodManager::FoodManager() { total = 0; } void FoodManager::addFood(Food f) { food[total++]=f; cout<<"成功添加了食物,目前共有"<<total<<endl; } void FoodManager::showFood() { cout<<"食物中共有"<<total<<"种"<<endl; cout<<"食物编号 "<<"名称\t\t"<<"单价"<<endl; for(int i = 0 ; i < total ; i ++ ) cout<<setw(10)<<setiosflags(ios::left)<<i<<setw(10)<<setiosflags(ios::left)<<food[i].getName()<<"\t"<<food[i].getPrice()<<endl; } void FoodManager::changePrice() { char *s; int code; s = new char[20]; double p; cout<<"请输入食物编号: "; cin>>code; s = food[code].getName(); cout<<"您选择了食物: "<<s<<endl; cout<<"请输入价格: "; cin>>p; for(int i = 0; i < total ; i ++) if(strcmp(food[i].getName(),s)==0) { food[i].setPrice(p); cout<<"修改成功"<<endl; return; } cout<<"没有这种食物,修改失败"<<endl; } void FoodManager::deleteFood() { char *s; s = new char[20]; cout<<"请输入菜名: "; cin>>s; for(int i = 0 ; i < total ; i ++) if(strcmp(food[i].getName(),s)==0) { cout<<"成功删除"<<s<<endl; total --; for(int t = i; t < total ; t ++) food[t]=food[t+1]; return; } cout<<"没有这种食物"<<endl; } void FoodManager::addFood(char *s , double p) { food[total++]=Food(s,p); } double FoodManager::getPriceByName(char *s) { for(int i = 0 ; i < total ; i ++) if(strcmp(food[i].getName(),s)==0) return food[i].getPrice(); return false; } int FoodManager::getListByName(char *s) { for(int i = 0 ; i < total ; i ++) if(strcmp(food[i].getName(),s)==0) return i; return false; } int FoodManager::getTotal() { return total; } char * FoodManager::getNameByList(int list) { return food[list].getName(); } void FoodManager::setTotal(int x) { total = x; } FeeManager.h #ifndef FEEMANAGER #define FEEMANAGER class FeeManager { private: double jiuCanFee; //就餐总收入 double waiMaiFee; //外卖总收入 public: FeeManager(); //结构函数 double getWaiMaiFee(); //返回外卖总收入 double getJiuCanFee(); //返回就餐总收入 void addWaiMaiFee(double x); //增加外卖总收入 void addJiuCanFee(double x); //添加就餐总收入 }; #endif FeeManager.cpp #include"FeeManager.h" FeeManager::FeeManager() { jiuCanFee = 0; waiMaiFee = 0; } double FeeManager::getWaiMaiFee() { return waiMaiFee; } double FeeManager::getJiuCanFee() { return jiuCanFee; } void FeeManager::addWaiMaiFee(double x) { waiMaiFee += x; } void FeeManager::addJiuCanFee(double x) { jiuCanFee += x; } MenuView.h #ifndef MENUVIEW #define MENUVIEW class MenuView { private: char whiteSmile; //白色笑脸 char blackSmile; //黑色笑脸 char heart; //心形图形 public: MenuView(); //结构函数 void showJiuCan(); //显示就餐用户点菜界面 void showWaiMai(); //显示外卖用户点菜界面 int showMain(); //显示用户选择就餐还是外卖界面 int showViewChoice(); //显示进入本系统功效选择界面 int showRegister(); //显示用户注册界面 int showClientChoice(); //显示用户点餐界面 int showQuery(); //显示查询用户订单界面 int showMend(); //显示修改食物界面 int showMenuChoice(); //显示选择菜单界面 int showMendDingDan(); //显示用户修改订单界面 }; #endif MenuView.cpp #include"MenuView.h" #include<iostream> using namespace std; MenuView::MenuView() { whiteSmile = 1; blackSmile = 2; heart = 3; } int MenuView::showMain() { for(int i = 1 ; i <= 80 ; i++ )cout<<heart; for(int i = 1;i<=80;i++){if(i==1||i==80)cout<<heart;else cout<<' ';} cout<<heart<<"\t\t\t\t欢迎光临本餐厅"; for(int j=1;j<=33;j++)cout<<' ';cout<<heart; for(int i = 1;i<=80;i++){if(i==1||i==80)cout<<heart;else cout<<' ';} for(int i = 1 ; i <= 80 ; i++ )cout<<heart; //输出餐厅外形 cout<<endl<<endl; cout<<"\t我是服务员小坠"<<whiteSmile<<",竭诚为您服务哦"<<blackSmile<<endl<<endl<<endl; for(int k=1;k<=10;k++)cout<<' '; for(int i = 1 ; i <= 20 ; i++ )cout<<heart;cout<<endl; for(int k=1;k<=10;k++)cout<<' '; cout<<heart<<"请选择您需要服务"<<heart<<endl; for(int k=1;k<=10;k++)cout<<' '; for(int i = 1 ; i <= 60 ; i++ )cout<<heart;cout<<endl; for(int k=1;k<=10;k++)cout<<' '; cout<<heart<<"1:就餐";for(int i = 1 ; i <= 52 ; i ++ )cout<<' ';cout<<heart<<endl; for(int k=1;k<=10;k++)cout<<' '; cout<<heart<<"2:外卖";for(int i = 1 ; i <= 52 ; i ++ )cout<<' ';cout<<heart<<endl; for(int k=1;k<=10;k++)cout<<' '; for(int i = 1 ; i <= 60 ; i++ )cout<<heart;cout<<endl<<endl; for(int i = 1;i<=7;i++) cout<<endl; cout<<"\t\t\t您选择是:"; int choice; cin>>choice; return choice; } void MenuView::showJiuCan() { cout<<"欢迎就餐,本餐厅有以下食品供您品尝"<<whiteSmile<<endl; } int MenuView::showViewChoice() { for(int i = 1 ; i <= 80 ; i++ )cout<<heart; for(int i = 1;i<=80;i++){if(i==1||i==80)cout<<heart;else cout<<' ';} cout<<heart<<"\t\t\t\t陈旺均特色餐厅"; for(int j=1;j<=33;j++)cout<<' ';cout<<heart; for(int i = 1;i<=80;i++){if(i==1||i==80)cout<<heart;else cout<<' ';} for(int i = 1 ; i <= 80 ; i++ )cout<<heart; cout<<endl<<endl; cout<<"------------------------"<<endl; cout<<"| 1:用户服务 |"<<endl; cout<<"| 2:食物管理 |"<<endl; cout<<"| 3:今日反馈 |"<<endl; cout<<"| 4:退出系统 |"<<endl; cout<<"------------------------"<<endl; cout<<"您选择是: "; int next; cin>>next; cout<<endl; return next; } int MenuView::showRegister() { cout<<"------------------------"<<endl; cout<<"| 1:新用户点餐 |"<<endl; cout<<"| 2:查询订单 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } int MenuView::showClientChoice() { cout<<"------------------------"<<endl; cout<<"| 1:加菜 |"<<endl; cout<<"| 2:修改订单 |"<<endl; cout<<"| 3:提交订单 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } int MenuView::showQuery() { cout<<"------------------------"<<endl; cout<<"| 1:查询订单 |"<<endl; cout<<"| 2:退出查询 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } int MenuView::showMend() { cout<<"------------------------"<<endl; cout<<"| 1:添加食物 |"<<endl; cout<<"| 2:修改价格 |"<<endl; cout<<"| 3:删除食物 |"<<endl; cout<<"| 4:退出食物管理 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } int MenuView::showMenuChoice() { cout<<"添加菜单:"<<endl; cout<<"------------------------"<<endl; cout<<"| 1:原菜单 |"<<endl; cout<<"| 2:更新后菜单 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } int MenuView::showMendDingDan() { cout<<"------------------------"<<endl; cout<<"| 1:修改数量 |"<<endl; cout<<"| 2:删除食物 |"<<endl; cout<<"| 3:退出修改 |"<<endl; cout<<"------------------------"<<endl; int next; cin>>next; return next; } Main.cpp #include<iostream> #include"Food.h" #include"MenuView.h" #include"FoodManager.h" #include"ClientManager.h" #include"FeeManager.h" #include<fstream> #include<iomanip> using namespace std; int main() { FeeManager feem;//管理就餐和外卖费用 MenuView mv; //管理界面 ClientManager cm; //管理用户类对象 FoodManager fm;//管理食物类对象 fstream ioFile; //文件输入输出 int clientChoice;// 1 服务用户 2 食物管理 3 今日反馈 4退出系统 int clientService;//1新用户点餐 2 查询 int mainChoice;// 1 就餐 2 外卖 int curClient; //目前操作用户编号 int queryChoice;//1 查询订单 2 退出查询 int foodChoice;//1 添加食物 2 修改食物价格 3删除某种食物 4退出食物管理 int viewChoice;//1 用户服务 2 食物管理 3 今日反馈 4 退出系统 int menuChoice;//1 原菜单 2 更新后菜单 int mendDingDanChoice;//1 修改数量 2 删除食物 3 退出修改 ioFile.open("C:\\Users\\Administrator\\Desktop\\food.txt",ios::in); while(!ioFile.eof()) { char *s; double p; s=new char[20]; ioFile>>s>>p; fm.addFood(s,p); } ioFile.close(); //以上是从文件读入食物种类和价格信息 while(true){ viewChoice = mv.showViewChoice(); if(viewChoice == 1) //用户服务 { clientService = mv.showRegister(); if(clientService == 1)//用户注册 { char *name,*phone; name = new char[30]; phone = new char[20]; cout<<"请完善用户资料"<<endl; cout<<"您订单号是"<<cm.getClientNum()+1<<endl; curClient = cm.getClientNum(); cout<<"请输入姓名: ";cin>>name; cout<<"请输入手机号码: ";cin>>phone; Client cc(name,phone); cc.setNumber(cm.getClientNum()); cm.addClient(cc); mainChoice = mv.showMain(); if(mainChoice == 1) //就餐 { cm.client[curClient].setType(1); mv.showJiuCan(); while(true) { fm.showFood(); int choices; choices = mv.showClientChoice(); if(choices==1)//选择食物种类和数量,下单 { char *n; int code; n = new char[20]; int num
展开阅读全文

开通  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 

客服