// 顾客类 class Customer { private: int id; // 乘客编号 string name; // 姓名 string sex; // 性别 string idCard; // 身份证号 string phone; // 电话 string address; // 住址 public: // 构造函数 Customer(int _id, string _name, string _sex, string _idCard, string _phone, string _address); // 获取顾客信息 void getInfo(); };

// 菜单类 class Menu { private: int id; // 菜品编号 double price; // 单价 string category; // 菜系 string chef; // 厨师 int duration; // 上菜时长 public: // 构造函数 Menu(int _id, double _price, string _category, string _chef, int _duration); // 获取菜品信息 void getInfo(); };

// 点菜类 class Order { private: int customerId; // 顾客编号 int menuId; // 菜品编号 int tableId; // 桌号 string date; // 日期 string time; // 时间 int quantity; // 数量 public: // 构造函数 Order(int _customerId, int _menuId, int _tableId, string _date, string _time, int _quantity); // 获取订单信息 void getInfo(); };

// 数据存储类 class DataStorage { public: // 存储顾客信息 void saveCustomer(Customer c); // 存储菜单信息 void saveMenu(Menu m); // 存储点菜信息 void saveOrder(Order o); // 查询顾客信息 void findCustomerById(int id); // 查询菜单信息 void findMenuById(int id); // 查询点菜信息 void findOrderByCustomerId(int customerId); void findOrderByMenuId(int menuId); };

// 主函数 int main() { // 创建数据存储对象 DataStorage ds; // 添加顾客信息 Customer c(1, '张三', '男', '123456789012345678', '13800138000', '北京市海淀区'); ds.saveCustomer(c); // 添加菜单信息 Menu m(1, 28.0, '川菜', '王师傅', 10); ds.saveMenu(m); // 添加点菜信息 Order o(1, 1, 101, '2021-05-01', '18:30', 2); ds.saveOrder(o); // 查询顾客信息 ds.findCustomerById(1); // 查询菜单信息 ds.findMenuById(1); // 查询点菜信息 ds.findOrderByCustomerId(1); ds.findOrderByMenuId(1); return 0; }

C++ 餐馆点菜信息管理系统代码示例 - 顾客、菜单、点菜类实现

原文地址: https://www.cveoy.top/t/topic/oyPy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录