C++自主点餐系统

一、 题目

设计一个自助点餐系统,方便顾客自己点餐,并提供对餐厅销售情况的统计和管理功能。

二、 业务流程图

三、 系统功能结构图

四、 类的设计

五、 程序代码与说明

头文件1.

c 复制代码
SystemMap.h
#pragma once
#ifndef SYSTEMMAP
#define SYSTEMMAP
#include<bits/stdc++.h>
using namespace std;
class SystemMap
{
private:
	string frame;
public:
	SystemMap();
	void showOutsideSystemMap(); // 外卖就餐页面
	void showInsideSystemMap();  //  店内就餐页面
	int showSystemMap();  //顾客选择系统页面
	int showChoiceMap();  //系统的功能选择界面
	int showRegMap();
	int showClientChoiceMap();
	int showQueryMap();
	int showMenuChoice();
	int showChangeMenuMap();
	int showCilentOrderMessage();
	int adminSystemMap();
	int showOrderChangeMap();
	int showPastSales();
};
#endif // !SYSTEMMAP

SystemMap.cpp

c 复制代码
#include "SystemMap.h"
SystemMap::SystemMap() {
	frame = "#";
}
int SystemMap::showSystemMap() {
	for (int i = 0; i < 60; i++)cout << frame;
	cout << endl;
	for (int i = 0; i < 60; i++) {
		if (i == 0 || i == 59)
			cout << frame;
		else
			cout << " ";
	}
	cout << endl;
	cout << "#\t\t\t欢迎光临本店";
	for (int i = 0; i < 23; i++)
		cout << " ";
	cout << "#\n";
	for (int i = 0; i < 60; i++) {
		if (i == 0 || i == 59)
			cout << frame;
		else
			cout << " ";
	}
	cout << endl;
	cout << "#\t\t  请问您需要什么服务\t\t";
	for (int i = 0; i < 11; i++)
		cout << " ";
	cout << "#\n";
	cout << "#\t\t  1:在店就餐";
	for (int i = 0; i < 31; i++)
		cout << " ";
	cout << "#\n";
	cout << "#\t\t  2:外卖就餐";
	for (int i = 0; i < 31; i++)
		cout << " ";
	cout << "#\n";
	for (int i = 0; i < 60; i++)cout << frame;
	cout << endl;
	cout << "\t\t  请问您选择的是:";
	int choice;
	cin >> choice;
	return choice;

}
void SystemMap::showInsideSystemMap() {
	cout << "欢迎您在本店就餐,以下是菜单\n\n";
}
void SystemMap::showOutsideSystemMap() {
	cout << "欢迎您点本店的外卖,以下是菜单\n\n";
}
int SystemMap::showChoiceMap() {
	for (int i = 0; i < 60; i++)cout << frame;
	cout << endl;
	for (int i = 0; i < 60; i++) {
		if (i == 0 || i == 59)
			cout << frame;
		else
			cout << " ";
	}
	cout << "\n#\t\t      欢迎来到榆榆餐厅";
	for (int i = 0; i < 21; i++)
		cout << " ";
	cout << "#\n";
	cout << "#\t\t\t店长:   陈榆";
	for (int i = 0; i < 23; i++)
		cout << " ";
	cout << "#\n";
	for (int i = 0; i < 60; i++) {
		if (i == 0 || i == 59)
			cout << frame;
		else
			cout << " ";
	}
	cout << endl;
	for (int i = 0; i < 60; i++)cout << frame;
	cout << endl;
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:顾客服务          |" << endl;
	cout << "\t\t|  2:管理员系统        |" << endl;
	cout << "\t\t|  3:退出系统          |" << endl;
	cout << "\t\t------------------------" << endl;
	cout << "\t\t您的选择是:";
	int choice;
	cin >> choice;
	return choice;
}
int SystemMap::adminSystemMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:食物管理          |" << endl;
	cout << "\t\t|  2:今日反馈          |" << endl;
	cout << "\t\t|  3:订单管理          |" << endl;
	cout << "\t\t|  4:历史销售情况      |" << endl;
	cout << "\t\t|  5:退出              |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cin >> choice;
	return choice;
}
int SystemMap::showRegMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:新顾客点餐        |" << endl;
	cout << "\t\t|  2:查询订单          |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showClientChoiceMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:点菜              |" << endl;
	cout << "\t\t|  2:修改订单          |" << endl;
	cout << "\t\t|  3:提交订单          |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showQueryMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:查询订单          |" << endl;
	cout << "\t\t|  2:退出              |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showChangeMenuMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:添加食物          |" << endl;
	cout << "\t\t|  2:修改食物价格      |" << endl;
	cout << "\t\t|  3:修改食物折扣      |" << endl;
	cout << "\t\t|  4:删除食物          |" << endl;
	cout << "\t\t|  5:退出食物管理系统  |" << endl;
	cout << "\t\t------------------------" << endl;
	cout << "\t\t您的选择是:";
	int choice;
	cin >> choice;
	return choice;
}
int SystemMap::showMenuChoice() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:原菜单            |" << endl;
	cout << "\t\t|  2:新菜单            |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showCilentOrderMessage() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:修改数量            |" << endl;
	cout << "\t\t|  2:删除食物            |" << endl;
	cout << "\t\t|  3:退出修改            |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showOrderChangeMap() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:查找订单            |" << endl;
	cout << "\t\t|  2:修改订单            |" << endl;
	cout << "\t\t|  3:删除订单            |" << endl;
	cout << "\t\t|  4:退出修改            |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}
int SystemMap::showPastSales() {
	cout << "\t\t------------------------" << endl;
	cout << "\t\t|  1:查找订单            |" << endl;
	cout << "\t\t|  2:修改订单            |" << endl;
	cout << "\t\t|  3:删除订单            |" << endl;
	cout << "\t\t|  4:退出修改            |" << endl;
	cout << "\t\t------------------------" << endl;
	int choice;
	cout << "\t\t您的选择是:";
	cin >> choice;
	return choice;
}

头文件2.

Admin.h

c 复制代码
#pragma once
#ifndef ADMIN
#define ADMIN
#include <bits/stdc++.h>
using namespace std;
class Admin
{
private:
	int num;
	string ID, password;
public:
	Admin();
	void setId(string I);
	void setPassword(string p);
	void setNum(int i);
	string getID();
	string getPassword();
	int getNum();
};
#endif // !ADMIN

Admin.cpp

c 复制代码
#include "Admin.h"
Admin::Admin() {

}

void Admin::setId(string I) {
	ID = I;
}

void Admin::setNum(int n) {
	num = n;
}

void Admin::setPassword(string P) {
	password = P;
}

string Admin::getID() {
	return ID;
}

string Admin::getPassword() {
	return password;
}

int Admin::getNum() {
	return num;
}

头文件3.

AdminManager.h

c 复制代码
#pragma once
#ifndef ADMINMANAGER
#define ADMINMANAGER
#include <bits/stdc++.h>
#include "Admin.h"
using namespace std;
class AdminManager
{
public:
	AdminManager();
	int adminNum;
	Admin admin[100];
	void addAdmin(string ,string );
	int getAdminNum();
	int checkPassword(string, string);
};
#endif // !ADMINMANAGER

AdminManager.cpp
#include "AdminManager.h"
AdminManager::AdminManager() {
	adminNum = 0;
}
void AdminManager::addAdmin(string ID,string p) {
	admin[adminNum].setId(ID);
	admin[adminNum].setPassword(p);
	admin[adminNum].setNum(adminNum + 1);
	adminNum++;
}
int AdminManager::checkPassword(string id,string p) {
	int i;
	for (i = 0; i < adminNum; i++) {
		if (admin[i].getID() == id) {
			if (admin[i].getPassword() == p) {
				cout << "密码正确\n\n";
				return 1;
			}
			else {
				cout << "密码错误\n\n";
				return 2;
			}
		}
	}
	if (i >= adminNum) {
		cout << "没有此账号的管理员,请先注册\n\n";
		return 3;
	}
}

int AdminManager::getAdminNum() {
	return adminNum;
}

头文件4.

Client.h

c 复制代码
#pragma once
#ifndef CLIENT
#define CLIENT
#include<bits/stdc++.h>
#include "Menu.h"
using namespace std;
class Client
{
private:
	int id, type, desk, arriveTime;// id 指的是 顾客编号    type   指就餐类型
	double coust; // 花费
	string name, phone, address; //姓名  电话  地址
public:
	Client();
	Client(string n, string p,int d);
	Client(string n, string p,string a);
	int judge = 1;//判断是否输出订单
	int num[100];
	Menu Client_Menu;
	string getName();
	string getPhone();
	string getAddress();
	int getDesk();
	double getCoust();
	int getType();
	int getDeskCoust();
	void setCoust(double);
	void setId(int);
	void setDesk(int);
	void setAddress(string a);
	void setType(int n);
	void addCoust(double x);
	void showCientMessage();
	void changeNum();
	void delFood();
	void setArriveTime(int);

};
#endif // CLIENT

Client.cpp

c 复制代码
#include "Client.h"
#include <iomanip>
Client::Client() {
	judge = 1;
}

Client::Client(string n, string p, int d) {
	name = n;
	phone = p;
	desk = d;
	coust = 0;
	for (int i = 0; i < 100; i++)
		num[i] = 0;
	cout << "顾客注册成功" << endl;
	judge = 1;
}

Client::Client(string n, string p, string a) {
	name = n;
	phone = p;
	address = a;
	coust = 0;
	for (int i = 0; i < 100; i++)
		num[i] = 0;
	cout << "顾客注册成功" << endl;
	judge = 1;
}

double Client::getCoust() {
	return coust;
}

string Client::getName() {
	return name;
}

string Client::getPhone() {
	return phone;
}

string Client::getAddress() {
	return address;
}

int Client::getType() {
	return type;
}

int Client::getDesk() {
	return desk;
}

int Client::getDeskCoust() {
	if (desk > 50)
		return 50;
	else
		return 0;
}

void Client::setAddress(string a) {
	address = a;
}


void Client::setDesk(int a) {
	desk = a;
	if (a >= 1 && a <= 50)
		cout << "\n您选择了" << a << "号餐桌" << endl;
	else {
		cout << "\n您选择了" << a << "号包厢" << endl;
		coust += 50;
	}
}


void Client::setType(int n) {
	type = n;
}

void Client::addCoust(double n) {
	coust += n;
}

void Client::setCoust(double a) {
	coust = 0;
}

void Client::showCientMessage() {

	if (judge == 1) {
		string a;
		if (type == 1)
		{
			a = "在店就餐";
			cout << "姓名:" << name << "\t\t" << a << endl;
			cout << "电话号码:" << phone << endl;
			cout << "餐桌号为:" << desk << endl << endl;
			cout << setw(10) << setiosflags(ios::left) << "食物序列" << setw(10) << "菜名" << "\t数量\t价格\t折扣" << endl;
			for (int i = 0; i < Client_Menu.getNum(); i++)
				cout << setw(10) << setiosflags(ios::left) << setw(10) << i + 1 << Client_Menu.food[i].getName() << "\t" << num[i] << "\t" << num[i] * Client_Menu.food[i].getRightPrice() << "\t" << Client_Menu.food[i].getDiscount() << endl;
			cout << "总价:\t" << coust + getDeskCoust() << "元\t\t含包厢费" << getDeskCoust() << "元" << endl << endl;
			cout << "--------------------------------------" << endl;
		}
		else {
			a = "外卖";
			cout << "姓名:" << name << "\t\t" << a << endl;
			cout << "电话号码:" << phone << endl;
			cout << "外卖送达地址:" << address << endl << endl;
			cout << setw(10) << setiosflags(ios::left) << "食物序列" << setw(10) << "菜名" << "\t数量\t价格\t折扣" << endl;
			for (int i = 0; i < Client_Menu.getNum(); i++)
				cout << setw(10) << setiosflags(ios::left) << setw(10) << i + 1 << Client_Menu.food[i].getName() << "\t" << num[i] << "\t" << num[i] * Client_Menu.food[i].getRightPrice() << "\t" << Client_Menu.food[i].getDiscount() << endl;
			int t = 5;
			//cout << "\n\n\n" << coust << "\n\n\n";
			cout << "总价:\t\t" << coust + 5 << "元\t" << "含外卖费" << 5 << "元" << endl << endl;
			cout << "预计到达时间:\t" << arriveTime << "分钟后\n";
			cout << "--------------------------------------" << endl;
		}
	}
	else {
		name = "";
		phone = "";
		address = "";
		desk = 0;
		coust = 0;
		arriveTime = 0;

		cout << "该订单已删除\n\n";
	}
	
}

void Client::setId(int i) {
	id = i;
}

void Client::changeNum() {
	int n,numss;
	cout << "请输入食物序列:";
	cin >> n;
	cout << "您选择了食物为:\t" << Client_Menu.food[n - 1].getName() << endl;
	cout << "请输入要改变该食物的数量:";
	cin >> numss;
	coust += (numss - num[n - 1]) * Client_Menu.getPriceByName(Client_Menu.getNameById(n - 1));
	num[n - 1] = numss;
}

void Client::delFood() {
	int n;
	cout << "请输入您的序列号:";
	cin >> n;
	cout << "您选择了食物:" << Client_Menu.food[n - 1].getName() << endl;
	coust -= num[n - 1] * Client_Menu.food[n - 1].getPrice();
	for (int i = n - 1; i < Client_Menu.getNum(); i++) {
		Client_Menu.food[i] = Client_Menu.food[i + 1];
		num[i] = num[i + 1];
	}
	Client_Menu.setNum(Client_Menu.getNum() - 1);
}

void Client::setArriveTime(int t) {
	
	arriveTime = t;
}

六、 运行结果与分析

一种是餐厅管理员,一种是顾客。餐厅管理员根据账号、密码登录系统。顾客无需登录即可使用系统。





七、联系与交流

q:969060742 完整代码、程序报告
相关推荐
何曾参静谧1 分钟前
「QT」文件类 之 QIODevice 输入输出设备类
开发语言·qt
爱吃生蚝的于勒1 小时前
C语言内存函数
c语言·开发语言·数据结构·c++·学习·算法
小白学大数据3 小时前
Python爬虫开发中的分析与方案制定
开发语言·c++·爬虫·python
冰芒猓4 小时前
SpringMVC数据校验、数据格式化处理、国际化设置
开发语言·maven
失落的香蕉4 小时前
C语言串讲-2之指针和结构体
java·c语言·开发语言
红中马喽4 小时前
JS学习日记(webAPI—DOM)
开发语言·前端·javascript·笔记·vscode·学习
杜杜的man4 小时前
【go从零单排】Closing Channels通道关闭、Range over Channels
开发语言·后端·golang
java小吕布5 小时前
Java中Properties的使用详解
java·开发语言·后端
versatile_zpc5 小时前
C++初阶:类和对象(上)
开发语言·c++
尘浮生5 小时前
Java项目实战II基于微信小程序的移动学习平台的设计与实现(开发文档+数据库+源码)
java·开发语言·数据库·spring boot·学习·微信小程序·小程序