仓库管理编写一个仓库管理程序管理仓库内货物的信息。仓库中货物信息的组成部分为:货物编号、货物名称、货物单价、货物数量等。1)增加或删除货物信息2)按编号或名称查询货物信息3)显示库存量不足一定值(由用房从键盘输入)的货物信息4)显示所有货物的信息5)用子函数实现各个子功能输入:程序正常运行后,屏幕上显示一个文字菜单(根据序号选定相应的操作项目),当用房选定操作项目所对应的序号时,根据应用程序的提示信息,从键盘上输入相应的数据。输出:1)应用程序正常运行后,要在屏幕上显示一个文字菜单2)要求用房输入数据时,要给出清晰、明确的提示信息,包括输入的数据内容、格式及结束方式等。

时间: 2024-03-13 13:45:42 浏览: 12
好的,这是一个比较简单的仓库管理程序,您可以参考以下代码实现: ```c++ #include <iostream> #include <vector> #include <string> using namespace std; // 定义货物类 class Goods { public: Goods(int id, string name, double price, int quantity) : id(id), name(name), price(price), quantity(quantity) {} int get_id() const { return id; } string get_name() const { return name; } double get_price() const { return price; } int get_quantity() const { return quantity; } void add_quantity(int amount) { quantity += amount; } void subtract_quantity(int amount) { quantity -= amount; } private: int id; string name; double price; int quantity; }; // 定义仓库类 class Warehouse { public: // 增加货物 void add_goods(int id, string name, double price, int quantity) { goods_list.emplace_back(id, name, price, quantity); } // 删除货物 void delete_goods(int id) { for (auto it = goods_list.begin(); it != goods_list.end(); ++it) { if (it->get_id() == id) { goods_list.erase(it); break; } } } // 按编号查询货物 void query_goods_by_id(int id) const { for (auto it = goods_list.begin(); it != goods_list.end(); ++it) { if (it->get_id() == id) { cout << "编号:" << it->get_id() << endl; cout << "名称:" << it->get_name() << endl; cout << "单价:" << it->get_price() << endl; cout << "数量:" << it->get_quantity() << endl; return; } } cout << "没有找到编号为" << id << "的货物" << endl; } // 按名称查询货物 void query_goods_by_name(const string& name) const { for (auto it = goods_list.begin(); it != goods_list.end(); ++it) { if (it->get_name() == name) { cout << "编号:" << it->get_id() << endl; cout << "名称:" << it->get_name() << endl; cout << "单价:" << it->get_price() << endl; cout << "数量:" << it->get_quantity() << endl; return; } } cout << "没有找到名称为" << name << "的货物" << endl; } // 显示库存不足的货物 void show_shortage_goods(int threshold) const { for (auto it = goods_list.begin(); it != goods_list.end(); ++it) { if (it->get_quantity() < threshold) { cout << "编号:" << it->get_id() << endl; cout << "名称:" << it->get_name() << endl; cout << "单价:" << it->get_price() << endl; cout << "数量:" << it->get_quantity() << endl; } } } // 显示所有货物 void show_all_goods() const { for (auto it = goods_list.begin(); it != goods_list.end(); ++it) { cout << "编号:" << it->get_id() << endl; cout << "名称:" << it->get_name() << endl; cout << "单价:" << it->get_price() << endl; cout << "数量:" << it->get_quantity() << endl; } } private: vector<Goods> goods_list; }; int main() { Warehouse warehouse; while (true) { cout << endl; cout << "请选择操作:" << endl; cout << "1. 增加货物" << endl; cout << "2. 删除货物" << endl; cout << "3. 按编号查询货物" << endl; cout << "4. 按名称查询货物" << endl; cout << "5. 显示库存不足的货物" << endl; cout << "6. 显示所有货物" << endl; cout << "7. 退出程序" << endl; int choice; cin >> choice; if (choice == 1) { int id, quantity; string name; double price; cout << "请输入货物编号:"; cin >> id; cout << "请输入货物名称:"; cin >> name; cout << "请输入货物单价:"; cin >> price; cout << "请输入货物数量:"; cin >> quantity; warehouse.add_goods(id, name, price, quantity); cout << "货物添加成功!" << endl; } else if (choice == 2) { int id; cout << "请输入要删除的货物编号:"; cin >> id; warehouse.delete_goods(id); cout << "货物删除成功!" << endl; } else if (choice == 3) { int id; cout << "请输入要查询的货物编号:"; cin >> id; warehouse.query_goods_by_id(id); } else if (choice == 4) { string name; cout << "请输入要查询的货物名称:"; cin >> name; warehouse.query_goods_by_name(name); } else if (choice == 5) { int threshold; cout << "请输入库存下限:"; cin >> threshold; warehouse.show_shortage_goods(threshold); } else if (choice == 6) { warehouse.show_all_goods(); } else if (choice == 7) { break; } else { cout << "无效的操作,请重新输入!" << endl; } } return 0; } ``` 这个程序中,我们定义了一个`Goods`类来存储每个货物的信息,包括编号、名称、单价、数量等。然后我们定义了一个`Warehouse`类来管理所有的货物,包括增加、删除、查询、显示等操作。在`main`函数中,我们使用一个循环来不断接收用户的输入,并执行相应的操作。

相关推荐

最新推荐

recommend-type

小型仓库管理系统的设计与实现(毕业论文)

小型仓库管理系统的设计与实现(毕业论文) -----------------来自网络 如有侵权 请联系删除
recommend-type

管理信息系统_仓库管理系统

管理信息系统_仓库管理系统 1.1系统使用环境:windows xp 、windows2000、visual foxpro 6.0 1.2开发方法:用visual foxpro 6.0完成了各个表和表单的设计。 1.3系统设计思路:
recommend-type

仓库管理信息系统 仓库管理信息系统 jsp

进行了数据库设计,以关系数据库设计理论为基础,参照仓库管理信息系统,将设计过程划分为需求分析、具体设计(包括逻辑数据库设计和物理数据库设计)、安全性设计以及数据库的访问四个部分并分别进行讨论。...
recommend-type

仓库管理系统--信息管理员信息系统专业毕业设计说明书

信息管理与信息系统专业2012年毕业设计说明书,仓库系统,参考了不少权威教科书和案例,由技术过硬的同学指导,可以作为你做毕业设计的一个参考。
recommend-type

大型仓库信息管理系统案例

大型仓库信息管理系统案例 一、 需求分析 二、系统用例模型 三、系统动态模型 四、创建系统包图 五、系统类模型 六、系统部署
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

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

用 Python 画一个可以动的爱心

好的,我可以帮助您使用Python来绘制一个动态的爱心。您可以使用turtle库来实现。以下是实现代码: ```python import turtle import math # 设置画布和画笔 canvas = turtle.Screen() canvas.bgcolor("black") pencil = turtle.Turtle() pencil.speed(0) pencil.color("red", "pink") pencil.pensize(3) # 定义爱心函数 def draw_love(heart_size, x_offset=0, y_offset=0):
recommend-type

JSBSim Reference Manual

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