C++餐厅管理系统源码(可运行)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
//Win10操作系统下,用VC6运行,文件后缀名应为.cpp
#include <iostream>//输入输出流
#include <fstream>//文件流
#include <iomanip>//用来对输入输出操作的格式进行更加方便的控制,在ios_base基类的基础上
#include <stdlib.h>//标准库头文件
#include<Windows.h>//Windows,图形界面接口,图形设备函数等重要的功能
using namespace std;
typedef struct bianhao
{
int num;//桌子编号
int seat;//座位数(顾客数)
int stat;//桌子状态
}bianhao_T;
//利用数组存桌子,三个参数分别为桌子编号、座位数、状态(是否有人在用)
bianhao_T A[10] = { {1, 2, 0},{2, 2, 0},{3, 2, 0},{4, 2, 0},{5, 2, 0},{6, 4, 0},{7, 4, 0},{8, 4, 0},{9, 4, 0},{10, 6, 0}
};
class Restaurant //餐厅类
{
private:
char location[50]; //座位
char phone_number[20];//电话号码
char evaluates[200];//评价
public:
void Search();//搜寻
void Set();//建立
void evaluate();//评价
};
class Customer //顾客类
{
private:
int desk; //桌子
char dishes[20];//菜品
int queues;//队列,排队
char write_evaluate[200];//客户书写评价
static int total;//总价格
public:
Customer();//顾客
void order();//菜
};
class Waiter//服务员类
{
private:
int job_number;//工作号
char name[25];//名字
char sex[5];//性别
char phone_number[20];//手机号码
public:
void Search();//搜索
void Set();//录入
};
class Menus//菜单类
{
private:
static int sums;//菜品总价
int number;//菜品序号
int price;//菜品价格
char dish_name[30];//菜品名字
public:
friend void Customer::order();
void Search();//查询
void Set();//录入
};
int Customer::total = 0;//顾客排队号
int Menus::sums = 0;//餐品总价格
void Welcome()
{
system("color b1");
cout << " ︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻" << endl;
cout << " 【︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻︻】" << endl;
cout << " 【【】】" << endl;
cout << " 【【★★★★ 】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【★欢迎使用★ 】】" << endl;
cout << " 【【】】" <<
endl;
cout << " 【【◆◆◆餐厅管理系统◆◆◆ 】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【-------------------------------- 】】" << endl;
cout << " 【【︱制作者:------、------、------ | 】】" << endl;
cout << " 【【-------------------------------- 】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【】】" << endl;
cout << " 【【】】" << endl;
cout << " 【︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼】" << endl;
cout << " ︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼︼" << endl;
}
//****全局函数***//
void Menu()
{
cout << " **** ****" << endl;
cout << " *** ** ** ***" << endl;
cout << " *** ** ** ***" << endl;
cout << " *** ~.~ - - ***" << endl;
cout << " *** 1、信息查询***" << endl;
cout << "*** ^.^ @.@ ***" << endl;
cout << "*** 2、信息录入***" << endl;
cout << " *** $.$ +.+ ***" << endl;
cout << " *** 3、顾客点餐***" << endl;
cout << " *** @.@ = = ***" << endl;
cout << " *** 4、接待顾客***" << endl;
cout << " *** ***" << endl;
cout << " *** 5、顾客评价***" << endl;
cout << " *** ***" << endl;
cout << " *** 0、退出***" << endl;
cout << " *** ***" << endl;
cout << " *** ***" << endl;
cout << " ***" << endl;
}
void Search()//查询菜单函数
{
system("cls");
cout << endl; cout << endl; cout << endl; cout << endl; cout << endl;
cout << "1、查询餐厅信息" << endl;
cout << endl;
cout << "2、查询服务员信息" << endl;
cout << endl;
cout << "3、查询菜单" << endl;
cout << endl;
cout << "4、查看评价" << endl;
cout << endl;
cout << "5、返回上一级菜单" << endl;
cout << endl;
cout << "" << "请选择:" << endl;
int choice;
Restaurant restaurant;
Waiter waiter;
Menus dish;
cin >> choice;
switch (choice)
{
case 1: restaurant.Search(); break;
case 2: waiter.Search(); break;
case 3: dish.Search(); break;
case 4: restaurant.evaluate(); break;
case 5:
system("cls");
Menu(); break;
}
}
//黄
int Arrange_table(int seat)//顾客桌子安排函数
{
int i = 0;
for (i = 0; i < 10; i++)
{
if (0 == A[i].stat)//判断桌子状态,是否被占用
{
if (A[i].seat >= seat)//如果桌子位置数大于等于人数,则安排此桌子,此桌子将被占用,状态变为1
{
A[i].stat = 1;
cout << "编号" << A[i].num << "的座位可安排" << seat << "人" << endl;
return A[i].num;//安排桌子
}
}
}
cout << "找不到可安排" << seat << "个人的座位,请顾客排队" << endl;
}
void reception()//接收顾客数
{
system("cls");
int seat = 0;
int num = 0;
cout << "请输入当前需要接待的顾客数:" << endl;
cin >> seat;
num = Arrange_table(seat);
system("pause");
system("cls");
Menu();
}
void orderdish()
{
Customer customer;
customer.order();
Menu();
}
void customer_evaluate()//顾客评价函数
{
char evaluate[200];
cout << "请评价:" << endl;
cin >> evaluate;
ofstream out("evaluate.txt", ios::app);
out << evaluate << endl;
out.close();
Menu();
}
void Restaurant::evaluate()
{
system("cls");
cout << endl << "历史评价:" << endl << endl;
ifstream in("evaluate.txt");
while (in >> evaluates)
cout << "" << evaluates << endl << endl;
in.close();
system("pause");
system("cls");
Menu();
}
Customer::Customer()
{}
void Customer::order()//顾客,点餐,计算总价
{
system("cls");
int temp[50];//点餐编号
int j = 0;
int sum = 0;//菜品总价
char flag = 'y';
int num = 0;
Menus menu[50];//菜品
cout << "菜单" << endl << endl;
ifstream in("Menus.txt");//以输入方式打开文件,从硬盘到内存
int i = 0;
while (in >> menu[i].number >> menu[i].dish_name >> menu[i].price)
{
cout << "" << menu[i].number << setw(10) << menu[i].dish_name << setw(10) << menu[i].price << endl;//输出菜品编号、名字、价格
i++;
}
in.close();//关闭文件
while (flag == 'y')
{
cout << "请点餐,选择相应编号:" << endl;
cin >> temp[num];
num++;
cout << "是否继续y or n" << endl;
cin >> flag;
}
for (j = 0; j < num; j++)//点几份菜
{
for (i = 0; i < 10; i++)
{
if (temp[j] == menu[i].number)//找到对应菜品编码
{
sum = sum + menu[i].price;//计算总价
}
}
}
cout << "总价钱:" << sum << endl;
system("pause");
system("cls");
}
//朱
void Set()//信息录入函数
{
system("cls");
cout << endl << endl << endl << endl;
cout << "1 添加菜品" << endl << endl;
cout << "2 添加服务员" << endl << endl;
cout << "3 添加餐厅信息" << endl << endl;
cout << "4 返回上一级菜单" << endl << endl;
cout << "请选择:" << endl;
Menus dish;
int choice;
Waiter waiter;
Restaurant restaurant;
cin >> choice;
switch (choice)
{
case 1:dish.Set(); break;
case 2:waiter.Set(); break;
case 3:restaurant.Set(); break;
case 4:
system("cls");
Menu();
break;
}
}
void Waiter::Set()
{
system("cls");
char flag = 'y';
do
{
cout << "输入服务员的工号,姓名,性别,电话号码:" << endl;
cin >> job_number >> name >> sex >> phone_number;
ofstream out("Waiter.txt");
out << job_number << " " << name << " " << sex << " " << phone_number << endl;
out.close();
cout << "是否继续是(y)否(n)" << endl;
cin >> flag;
} while (flag == 'y');
Menu();
}
void Menus::Set()
{
system("cls");
char flag = 'y';
do
{
sums++;
cout << "输入编号,菜名,价格" << endl;
cin >> number >> dish_name >> price;
ofstream out("Menus.txt", ios::app);
out << number << " " << dish_name << " " << price << " " << endl;
out.close();
cout << "是否继续是(y)否(n)" << endl;
cin >> flag;
} while (flag == 'y');
system("pause");
system("cls");
Menu();
}
void Restaurant::Set()
{
system("cls");
cout << "输入餐厅位置,电话号码" << endl;
cin >> location >> phone_number;
ofstream out("Restaurant.txt");
out << location << " " << phone_number << endl;
out.close();
system("pause");
system("cls");
Menu();
}
//吴
void Restaurant::Search()
{
system("cls");
cout << endl << endl;
ifstream in("Restaurant.txt");
cout << "地址" << "" << "联系电话" << endl;
while (in >> location >> phone_number)
{
cout << location << "" << phone_number << endl;
}
in.close();
cout << endl << endl;
system("pause");
system("cls");
Menu();
}
void Waiter::Search()
{
system("cls");
ifstream in("Waiter.txt");
cout << endl << endl;
cout << "工号" << " " << "姓名" << " " << "性别" << " " << "电话号码" << endl;
while (in >> job_number >> name >> sex >> phone_number)
{
cout << " " << job_number << " " << name << " " << sex << " " << phone_number << endl;
}
in.close();
system("pause");
system("cls");
Menu();
}
void Menus::Search()
{
system("cls");
ifstream in("Menus.txt");
cout << endl << endl;
cout << "编号" << setw(10) << "菜名" << setw(10) << "价格" << endl;
while (in >> number >> dish_name >> price)
{
cout << " " << number << " " << setw(10) << dish_name << setw(10) << price << endl;
}
in.close();
system("pause");
system("cls");
Menu();
}
int main()
{
Welcome();
Sleep(3000);
system("cls");
Menu();
do
{
cout << "请输入你的选择:" << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:Search(); break;
case 2:Set(); break;
case 3:orderdish(); break;
case 4:reception(); break;
case 5:customer_evaluate(); break;
case 0:exit(1); break;
}
} while (1);
return 0;
}。