java实验仓库管理系统数据结构设计
时间: 2023-12-04 22:41:42 浏览: 35
根据提供的引用内容,我们可以了解到该仓库管理系统是基于JSP开发的,因此可以使用Java语言进行数据结构设计。以下是一个简单的Java实验仓库管理系统数据结构设计:
1. 物品类Item
```java
public class Item {
private int id; // 物品编号
private String name; // 物品名称
private int quantity; // 物品数量
// 构造函数
public Item(int id, String name, int quantity) {
this.id = id;
this.name = name;
this.quantity = quantity;
}
// getter和setter方法
public int getId() {
return id; }
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
```
2. 仓库类Warehouse
```java
import java.util.ArrayList;
public class Warehouse {
private ArrayList<Item> itemList; // 物品列表
// 构造函数
public Warehouse() {
itemList = new ArrayList<Item>(); }
// 添加物品
public void addItem(Item item) {
itemList.add(item);
}
// 删除物品
public void removeItem(Item item) {
itemList.remove(item);
}
// 根据编号查找物品
public Item findItemById(int id) {
for (Item item : itemList) {
if (item.getId() == id) {
return item;
}
}
return null;
}
// 根据名称查找物品
public ArrayList<Item> findItemByName(String name) {
ArrayList<Item> result = new ArrayList<Item>();
for (Item item : itemList) {
if (item.getName().equals(name)) {
result.add(item);
}
}
return result;
}
// 获取所有物品
public ArrayList<Item> getAllItems() {
return itemList;
}
}
```
3. 入库类Inbound
```java
import java.util.Date;
public class Inbound {
private int id; // 入库编号
private Item item; // 入库物品
private int quantity; // 入库数量
private Date date; // 入库日期
// 构造函数
public Inbound(int id, Item item, int quantity, Date date) {
this.id = id;
this.item = item;
this.quantity = quantity;
this.date = date;
}
// getter和setter方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
```
4. 出库类Outbound
```java
import java.util.Date;
public class Outbound {
private int id; // 出库编号
private Item item; // 出库物品
private int quantity; // 出库数量
private Date date; // 出库日期
// 构造函数
public Outbound(int id, Item item, int quantity, Date date) {
this.id = id;
this.item = item;
this.quantity = quantity;
this.date = date;
}
// getter和setter方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
```