C++课程设计自助点餐系统.docx
《C++课程设计自助点餐系统.docx》由会员分享,可在线阅读,更多相关《C++课程设计自助点餐系统.docx(29页珍藏版)》请在冰豆网上搜索。
C++课程设计自助点餐系统
面向对象程序课程设计
(2014/2015学年第一学期第20周)
指导教师:
庄巧莉、杨东鹤
班级:
计算机科学与技术13
(1)
学号:
姓名:
面向对象程序课程设计
一、题目
二、需求分析
三、系统结构图
四、类的设计
五、程序代码与说明
六、运行结果与分析
七、心得与体会
一:
题目
自助点餐系统
二:
需求分析
有一个小型餐厅,该餐厅提供即时就餐和外卖服务。
现在这个餐厅打算使用自助点餐系统,让顾客自己点餐,实现以下功能。
1、根据顾客的选择正确打出账单
2、正确统计出每一天的及时就餐和外卖的销售情况
3、实现对餐厅菜式和价格的有效管理
4、考虑点餐的自动排序问题,使顾客可以实时查询到自己菜单处理情况
三:
系统结构图
四:
类的设计
Client类:
客户类,包含客户属性姓名,电话号码,费用等信息,登记客户,记录客户订单信息
ClientManager类:
客户管理类,用于管理客户,记录客户数量,存储客户菜单信息,查询客户订单信息,统计订单
FeeManager类:
用于记录就餐、外卖的销售费用,统计收入
Food类:
餐厅食物的类,包含食物名称和价格
FoodManager类:
管理菜单,用于添加食物,修改食物,删除食物,记录不同食物的信息,呈现菜单
MenuView类:
用于打印各种操作界面
五:
程序代码与说明
Client.h
#ifndefCLIENT
#defineCLIENT
#include"FoodManager.h"
#include
usingnamespacestd;
classClient
{
private:
intnumber;//客户编号
inttype;//客户的类型,1表示就餐,2表示外卖
doublefee;//客户账单费用
char*name;//客户名称
char*phone;//客户手机号码
public:
Client(){}//构造函数
char*getName();//返回客户姓名
intnum[100];//num[i]存储食物数量,i表示食物编号
FoodManagerclient_fm;//管理客户所点的食物
Client(char*n,char*p);//构造函数
intgetNumber();//返回客户编号
voidsetNumber(intn);//设置客户编号
intgetType();//返回客户类型
voidsetType(intn);//设置客户类型
voidaddFee(doublex);//添加费用
doublegetFee();//返回费用
voidshowClientMessage();//展示客户信息
voidchangNum();//修改客户所点的食物的数量
voiddeleFood();//删除客户所选择的食物
};
#endif
Client.cpp
#include"Client.h"
#include
Client:
:
Client(char*s,char*p)
{
name=s;
phone=p;
fee=0;
for(inti=0;i<100;i++)
num[i]=0;
cout<<"客户注册成功"<}
intClient:
:
getNumber()
{
returnnumber;
}
voidClient:
:
setNumber(intn)
{
number=n;
}
intClient:
:
getType()
{
returntype;
}
voidClient:
:
setType(intn)
{
type=n;
}
voidClient:
:
addFee(doublex)
{
fee+=x;
}
doubleClient:
:
getFee()
{
returnfee;
}
voidClient:
:
showClientMessage()
{
char*ss;
if(type==1)ss="就餐";
elseif(type==2)ss="外卖";
cout<<"姓名:
"<cout<<"手机号码:
"<cout<<"订单总价:
"<cout<<"订单详情:
"<cout<:
left)<<"食物序列"<:
left)<<"菜名"<<"\t数量\t价格"<for(inti=0;i{
cout<:
left)<:
left)<}
cout<<"总价:
\t\t"<}
char*Client:
:
getName()
{
returnname;
}
voidClient:
:
changNum()
{
intn;
intnumss;
cout<<"请输入食物序号:
";cin>>n;
cout<<"您选择了食物:
"<cout<<"请输入数量:
";cin>>numss;
fee+=(numss-num[n-1])*client_fm.getPriceByName(client_fm.getNameByList(n-1));
num[n-1]=numss;
}
voidClient:
:
deleFood()
{
intn;
cout<<"请输入食物序号:
";cin>>n;
cout<<"您选择了食物:
"<fee-=(num[n-1])*client_fm.getPriceByName(client_fm.getNameByList(n-1));
for(inti=n-1;i{
client_fm.food[i]=client_fm.food[i+1];
num[i]=num[i+1];
}
client_fm.setTotal(client_fm.getTotal()-1);
}
ClientManager.h
#ifndefCLIENTMANAGER
#defineCLIENTMANAGER
#include"Client.h"
#include
usingnamespacestd;
#defineMAX_CLIENT_NUM60//最大客户数量
classClientManager
{
public:
ClientManager();//构造函数
intclientNum;//记录客户数量
Clientclient[MAX_CLIENT_NUM];//记录存储客户
voidaddClient(Clientc);//添加新客户
intgetClientNum();//返回客户数量
voidshowQuery(char*s);//查询客户
voidshowAll();//显示所有客户
};
#endif
ClientManager.cpp
#include"ClientManager.h"
ClientManager:
:
ClientManager()
{
clientNum=0;
}
voidClientManager:
:
addClient(Clientc)
{
client[clientNum++]=c;
cout<<"客户注册成功"<}
intClientManager:
:
getClientNum()
{
returnclientNum;
}
voidClientManager:
:
showQuery(char*s)
{
intcount=0;
intth;
cout<<"----------------------------------"<for(inti=0;iif(client[i].getType()==1)
{
cout<<"第"<<++count<<"单:
"<"<if(strcmp(client[i].getName(),s)==0)th=count;
}
for(inti=0;iif(client[i].getType()==2)
{
cout<<"第"<<++count<<"单:
"<"<if(strcmp(client[i].getName(),s)==0)th=count;
}
cout<<"您当前排在第"<
cout<<"----------------------------------"<} voidClientManager: : showAll() { for(inti=0;i{ if(client[i].getType()==1) { cout<<"订单号: "< client[i].showClientMessage(); cout<} } for(inti=0;i{ if(client[i].getType()==2) { cout<<"订单号: "< client[i].showClientMessage(); cout<} } } Food.h #ifndefFOOD #defineFOOD classFood { private: char*name;//食物名称 doubleprice;//食物价格 public: Food(){};//构造函数 Food(char*s,doublep);//构造函数 voidsetName(char*s);//更改食物名称 char*getName();//返回食物名称 doublegetPrice();//返回食物价格 voidsetPrice(doublep);//设置食物价格 voidshowMessage();//显示食物的名称和价格 }; #endif Food.cpp #include"Food.h" #include usingnamespacestd; Food: : Food(char*s,doublep) { name=s; price=p; } voidFood: : setName(char*s) { name=s; } voidFood: : setPrice(doublep) { price=p; } voidFood: : showMessage() { cout<"<} doubleFood: : getPrice() { returnprice; } char*Food: : getName() { returnname; } FoodManager.h #ifndefFOODMANAGER #defineFOODMANAGER #include"Food.h" #defineMAX_FOOD_NUM99//最多容纳的食物种类数 classFoodManager { inttotal;//食物种类数 public: FoodManager();//构造函数 intgetTotal();//返回食物种类数 Foodfood[MAX_FOOD_NUM];//记录食物 voidaddFood(Foodf);//添加食物 voidaddFood(char*s,doublep);//添加食物 voiddeleteFood();//删除食物 voidchangePrice();//修改食物价格 voidshowFood();//显示食物信息 char*getNameByList(intlist);//通过食物编号返回食物名称 doublegetPriceByName(char*s);//通过食物名称返回食物价格 intgetListByName(char*s);//通过食物名称返回食物编号 voidsetTotal(intx);//修改食物种类数 }; #endif FoodManager.cpp #include"FoodManager.h" #include usingnamespacestd; #include FoodManager: : FoodManager() { total=0; } voidFoodManager: : addFood(Foodf) { food[total++]=f; cout<<"成功添加了食物,当前共有"<} voidFoodManager: : showFood() { cout<<"食物中共有"<cout<<"食物编号"<<"名称\t\t"<<"单价"<for(inti=0;icout<: left)< : left)<} voidFoodManager: : changePrice() { char*s; intcode; s=newchar[20]; doublep; cout<<"请输入食物编号: "; cin>>code; s=food[code].getName(); cout<<"您选择了食物: "< cout<<"请输入价格: "; cin>>p; for(inti=0;iif(strcmp(food[i].getName(),s)==0) { food[i].setPrice(p); cout<<"修改成功"<return; } cout<<"没有这种食物,修改失败"<} voidFoodManager: : deleteFood() { char*s; s=newchar[20]; cout<<"请输入菜名: "; cin>>s; for(inti=0;iif(strcmp(food[i].getName(),s)==0) { cout<<"成功删除"< total--; for(intt=i;tfood[t]=food[t+1]; return; } cout<<"没有这种食物"<} voidFoodManager: : addFood(char*s,doublep) { food[total++]=Food(s,p); } doubleFoodManager: : getPriceByName(char*s) { for(inti=0;iif(strcmp(food[i].getName(),s)==0) returnfood[i].getPrice(); returnfalse; } intFoodManager: : getListByName(char*s) { for(inti=0;iif(strcmp(food[i].getName(),s)==0) returni; returnfalse; } intFoodManager: : getTotal() { returntotal; } char*FoodManager: : getNameByList(intlist) { returnfood[list].getName(); } voidFoodManager: : setTotal(intx) { total=x; } FeeManager.h #ifndefFEEMANAGER #defineFEEMANAGER classFeeManager { private: doublejiuCanFee;//就餐总收入 doublewaiMaiFee;//外卖总收入 public: FeeManager();//构造函数 doublegetWaiMaiFee();//返回外卖总收入 doublegetJiuCanFee();//返回就餐总收入 voidaddWaiMaiFee(doublex);//增加外卖总收入 voidaddJiuCanFee(doublex);//添加就餐总收入 }; #endif FeeManager.cpp #include"FeeManager.h" FeeManager: : FeeManager() { jiuCanFee=0; waiMaiFee=0; } doubleFeeManager: : getWaiMaiFee() { returnwaiMaiFee; } doubleFeeManager: : getJiuCanFee() { returnjiuCanFee; } voidFeeManager: : addWaiMaiFee(doublex) { waiMaiFee+=x; } voidFeeManager: : addJiuCanFee(doublex) { jiuCanFee+=x; } MenuView.h #ifndefMENUVIEW #defineMENUVIEW classMenuView { private: charwhiteSmile;//白色笑脸 charblackSmile;//黑色笑脸 charheart;//心形图形 public: MenuView();//构造函数 voidshowJiuCan();//显示就餐用户点菜界面 voidshowWaiMai();//显示外卖用户点菜界面 intshowMain();//显示用户选择就餐还是外卖界面 intshowViewChoice();//显示进入本系统的功能选择界面 intshowRegister();//显示客户注册界面 intshowClientChoice();//显示客户点餐界面 intshowQuery();//显示查询客户订单界面 intshowMend();//显示修改食物界面 intshowMenuChoice();//显示选择菜单界面 intshowMendDingDan();//显示客户修改订单界面 }; #endif MenuView.cpp #include"MenuView.h" #include usingnamespacestd; MenuView: : MenuView() { whiteSmile=1; blackSmile=2; heart=3; } intMenuView: : showMain() { for(inti=1;i<=80;i++)cout<for(inti=1;i<=80;i++){if(i==1||i==80)cout<cout<for(intj=1;j<=33;j++)cout<<'';cout<for(inti=1;i<=80;i++){if(i==1||i==80)cout<for(inti=1;i<=80;i++)cout<//输出餐厅的外形 cout<cout<<"\t我是服务员小坠"<
展开阅读全文
相关搜索
|