项目实现:通过主菜单选择需要的服务,实现网上点餐,支付功能
#include <iostream>
#include <fstream>//设置文件
#include <string>
#include <conio.h>//等待输入
using namespace std;
/*
食物
名字
价格
种类
*/
class food
{
public:
string name;
int price;
food(){}
food(string na,int pr):name(na),price(pr){}
};
food zhushi[3]={food("米饭",2),food("花卷",1),food("白饼",3)};
food liangcai[3]={food("蒜蓉油麦",10),food("拍黄瓜 ",11),food("凉拌海蜇",12)};
food recai[3]={food("鱼香肉丝",23),food("肉沫茄子",13),food("松鼠鳜鱼",35)};
food soup[3]={food("西湖牛肉羹",20),food("紫菜蛋花汤",15),food("醪糟汤 ",17)};
food drink[3]={food("可乐",3),food("雪碧",3),food("啤酒",5)};
主食
food myfood[15];
int money=0;
int num=0;
//主食
void xuanzhushi()
{
void Menu();
void Diancan();
system("cls");
cout<<"\r\n";
cout<<"\r\n";
cout<<"\t\t\t主食有:\r\n";
cout<<"\t\t\t\t\t**************************************\r\n";
cout<<"\t\t\t\t\t* 1、"<<zhushi[0].name<<" 价格:"<<zhushi[0].price<<" *"<<endl;
cout<<"\t\t\t\t\t* 2、"<<zhushi[1].name<<" 价格:"<<zhushi[1].price<<" *"<<endl;
cout<<"\t\t\t\t\t* 3、"<<zhushi[2].name<<" 价格:"<<zhushi[2].price<<" *"<<endl;
cout<<"\t\t\t\t\t* *\r\n";
cout<<"\t\t\t\t\t* 4、返回 *"<<endl;
cout<<"\t\t\t\t\t**************************************\r\n";
char c;
c=getch();
switch(c)
{
case'1': myfood[num]=zhushi[0];money+=zhushi[0].price;num++;
printf("米饭");
break;
case'2': myfood[num]=zhushi[1];money+=zhushi[1].price;num++;
printf("花卷");
break;
case'3': myfood[num]=zhushi[2];money+=zhushi[2].price;num++;
printf("白饼");
break;
case'4': Diancan(); break;
default:
printf("\n输入有误!请重新选择!\n");
getch();
xuanzhushi();
}
printf("\n点餐成功!请按任意键继续点餐或者返回!\n");
getch();
if(num>30)
{
cout<<"您本次点餐已达上限!如果需要!请结算后继续点餐"<<endl;
printf("\n请按任意键返回主菜单\n");
getch();
Menu();
}
else xuanzhushi();
}
菜品
//热菜
void xuanrecai()
{
void Menu();
void Diancan();