c++实现题目:餐饮业管理系统 基本要求:设计一个餐饮业管理系统,使之能提供以下基本功能: (1) 输入顾客(顾客桌号、排队号、所点菜(若干)); (2) 修改(顾客点菜信息、菜品信息); (3) 显示(顾客、菜品等信息) (4) 顾客结账。

时间: 2023-06-27 15:08:31 浏览: 55
以下是一个简单的C++实现餐饮业管理系统的示例代码: ```c++ #include <iostream> #include <vector> #include <string> using namespace std; // 菜品类定义 class Dish { public: string name; // 菜名 double price; // 价格 int quantity; // 数量 Dish(string n, double p, int q) { name = n; price = p; quantity = q; } }; // 顾客类定义 class Customer { public: int tableNo; // 桌号 int queueNo; // 排队号 vector<Dish> dishes; // 点的菜品 Customer(int tn, int qn) { tableNo = tn; queueNo = qn; } }; // 餐厅类定义 class Restaurant { public: vector<Customer> customers; // 所有顾客 vector<Dish> dishes; // 所有菜品 // 添加菜品 void addDish(string name, double price, int quantity) { dishes.push_back(Dish(name, price, quantity)); } // 显示所有菜品 void showAllDishes() { cout << "所有菜品:" << endl; for (int i = 0; i < dishes.size(); i++) { cout << dishes[i].name << " 价格:" << dishes[i].price << " 数量:" << dishes[i].quantity << endl; } cout << endl; } // 显示指定桌号的顾客信息 void showCustomerInfo(int tableNo) { for (int i = 0; i < customers.size(); i++) { if (customers[i].tableNo == tableNo) { cout << "桌号:" << customers[i].tableNo << " 排队号:" << customers[i].queueNo << endl; cout << "所点菜品:" << endl; for (int j = 0; j < customers[i].dishes.size(); j++) { cout << customers[i].dishes[j].name << " 价格:" << customers[i].dishes[j].price << " 数量:" << customers[i].dishes[j].quantity << endl; } cout << endl; } } } // 顾客结账 void checkOut(int tableNo) { double total = 0; for (int i = 0; i < customers.size(); i++) { if (customers[i].tableNo == tableNo) { for (int j = 0; j < customers[i].dishes.size(); j++) { total += customers[i].dishes[j].price * customers[i].dishes[j].quantity; } customers.erase(customers.begin() + i); break; } } cout << "桌号:" << tableNo << " 账单:" << total << endl; } // 修改指定桌号的顾客点菜信息 void modifyOrder(int tableNo, string dishName, int quantity) { for (int i = 0; i < customers.size(); i++) { if (customers[i].tableNo == tableNo) { for (int j = 0; j < customers[i].dishes.size(); j++) { if (customers[i].dishes[j].name == dishName) { customers[i].dishes[j].quantity = quantity; break; } } break; } } } // 修改指定菜品信息 void modifyDish(string dishName, double price, int quantity) { for (int i = 0; i < dishes.size(); i++) { if (dishes[i].name == dishName) { dishes[i].price = price; dishes[i].quantity = quantity; break; } } } }; int main() { Restaurant restaurant; // 添加菜品 restaurant.addDish("鱼香肉丝", 28.0, 10); restaurant.addDish("宫保鸡丁", 25.0, 8); restaurant.addDish("回锅肉", 35.0, 5); // 显示所有菜品 restaurant.showAllDishes(); // 添加顾客并点菜 Customer c1(1, 1); c1.dishes.push_back(Dish("鱼香肉丝", 28.0, 2)); c1.dishes.push_back(Dish("宫保鸡丁", 25.0, 3)); restaurant.customers.push_back(c1); // 显示指定桌号的顾客信息 restaurant.showCustomerInfo(1); // 顾客结账 restaurant.checkOut(1); // 修改指定桌号的顾客点菜信息 restaurant.modifyOrder(1, "鱼香肉丝", 3); // 修改指定菜品信息 restaurant.modifyDish("鱼香肉丝", 30.0, 5); return 0; } ``` 在这个示例代码中,我们定义了三个类:Dish(菜品)、Customer(顾客)和Restaurant(餐厅)。其中,Dish和Customer类用来存储菜品和顾客信息,Restaurant类用来实现餐饮业管理系统的基本功能。 在Restaurant类中,我们实现了以下基本功能: - 添加菜品; - 显示所有菜品; - 显示指定桌号的顾客信息; - 顾客结账; - 修改指定桌号的顾客点菜信息; - 修改指定菜品信息。 你可以根据自己的需求对这些功能进行修改和扩展。

相关推荐

最新推荐

recommend-type

C++ 学生成绩管理系统设计报告书

基本实现了: (1)学生基本信息、考试科目及成绩的信息录入。 (2)已有学生信息的显示。 (3)学生基本信息的读取和保存输入数据等功能 (4)学生基本信息的查询与修改。可以对已有的学生信息进行修改。 (5)学生基本信息的...
recommend-type

C++实现病人就医管理系统

主要为大家详细介绍了C++语言实现病人就医管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

C++学校人员信息管理系统课程设计.doc

一个用C++写的学校人员管理系统,适合大一大二的课程设计,里面运用到了链表、文件读写等一些C++基本语法操作
recommend-type

学籍管理系统源代码 c++.docx

为了学校更加高效,快捷,方便的管理学生信息,并实现以下功能: (1)对学生信息进行录入:先输入学生的学籍,然后输入学生姓名,年龄,性别,籍贯,系别,专业,班级等,最后输入学生状态(入学)。 (2)对已录取...
recommend-type

诊所信息管理系统C++课程设计报告.doc

模拟诊所信息管理系统就是对存储患者信息以及医生信息在个人PC上的编程实现。本系统采用了用户身份的注册、登陆、增加信息、查询信息、帐单信息以及统计所有患者的总费用等功能。并分析在现实生活中遇到的问题并得到...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。