用C++写烧烤管理系统
时间: 2023-11-05 08:04:19 浏览: 124
好的,一个烧烤店管理系统通常需要包含以下功能:
1. 菜单管理:管理烧烤店的菜单,包括菜品、价格、库存等信息。
2. 订单管理:记录客户点餐信息、结算等。
3. 库存管理:记录库存信息,包括食材等。
4. 员工管理:管理员工信息、考勤记录等。
5. 数据统计:对烧烤店的营业额、销售情况等进行统计。
6. 系统设置:对系统进行设置,如修改密码、备份数据、日志记录等。
以下是一个简单的烧烤店管理系统的代码示例:
```c++
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Dish {
private:
string name;
double price;
int stock;
public:
Dish(string name, double price, int stock) {
this->name = name;
this->price = price;
this->stock = stock;
}
string getName() {
return name;
}
double getPrice() {
return price;
}
int getStock() {
return stock;
}
void setStock(int stock) {
this->stock = stock;
}
};
class Order {
private:
vector<Dish> dishes;
double totalPrice;
public:
Order() {
totalPrice = 0;
}
void addDish(Dish dish) {
dishes.push_back(dish);
totalPrice += dish.getPrice();
}
double getTotalPrice() {
return totalPrice;
}
};
class Inventory {
private:
vector<Dish> dishes;
public:
void addDish(Dish dish) {
dishes.push_back(dish);
}
void updateStock(string name, int stock) {
for (int i = 0; i < dishes.size(); i++) {
if (dishes[i].getName() == name) {
dishes[i].setStock(stock);
break;
}
}
}
int getStock(string name) {
for (int i = 0; i < dishes.size(); i++) {
if (dishes[i].getName() == name) {
return dishes[i].getStock();
}
}
return -1;
}
};
class Employee {
private:
string name;
string password;
public:
Employee(string name, string password) {
this->name = name;
this->password = password;
}
string getName() {
return name;
}
bool checkPassword(string password) {
return this->password == password;
}
};
class Statistic {
private:
double totalSales;
int totalOrders;
public:
Statistic() {
totalSales = 0;
totalOrders = 0;
}
void addOrder(Order order) {
totalSales += order.getTotalPrice();
totalOrders++;
}
double getTotalSales() {
return totalSales;
}
int getTotalOrders() {
return totalOrders;
}
};
class System {
private:
vector<Employee> employees;
Inventory inventory;
Statistic statistic;
public:
System() {
// 初始化员工信息、菜单信息等
employees.push_back(Employee("admin", "123456"));
inventory.addDish(Dish("烤羊肉串", 1.5, 100));
inventory.addDish(Dish("烤牛肉串", 2, 80));
inventory.addDish(Dish("烤鸡翅", 1, 150));
}
bool login(string name, string password) {
for (int i = 0; i < employees.size(); i++) {
if (employees[i].getName() == name) {
return employees[i].checkPassword(password);
}
}
return false;
}
void order(string name) {
int stock = inventory.getStock(name);
if (stock > 0) {
Order order;
order.addDish(Dish(name, 0, 0));
inventory.updateStock(name, stock - 1);
statistic.addOrder(order);
cout << "点餐成功" << endl;
} else {
cout << "库存不足" << endl;
}
}
void showStatistic() {
cout << "总销售额:" << statistic.getTotalSales() << endl;
cout << "总订单数:" << statistic.getTotalOrders() << endl;
}
};
int main() {
System system;
string name, password;
cout << "请输入用户名和密码:" << endl;
cin >> name >> password;
if (system.login(name, password)) {
cout << "登录成功" << endl;
while (true) {
cout << "请选择操作:" << endl;
cout << "1. 点餐" << endl;
cout << "2. 统计信息" << endl;
cout << "3. 退出" << endl;
int choice;
cin >> choice;
if (choice == 1) {
cout << "请输入菜名:" << endl;
cin >> name;
system.order(name);
} else if (choice == 2) {
system.showStatistic();
} else if (choice == 3) {
break;
}
}
} else {
cout << "用户名或密码错误" << endl;
}
return 0;
}
```
以上是一个简单的烧烤店管理系统的代码示例,供您参考。
阅读全文