package test;
public class WarehouseInformation {
private String itemno;//编号,八位数字
private String itemname;//名称
private String suppliername;//供货商
private String warehousingtime;//入库时间,八位数字
private String shipmenttime;//出库时间,八位数字
private String warehousenumber;//仓库编号,三位数字
private String warehouseplace;//位置
private int itemnumber;//入库数量
private int outnumber;//出库数量
public String getItemno() {
return itemno;
}
public String getItemname() {
return itemname;
}
public String getSuppliername() {
return suppliername;
}
public String getWarehousingtime() {
return warehousingtime;
}
public String getShipmenttime() {
return shipmenttime;
}
public String getWarehousenumber() {
return warehousenumber;
}
public String getWarehouseplace() {
return warehouseplace;
}
public int getItemnumber() {
return itemnumber;
}
public int getOutnumber() {
return outnumber;
}
public void setItemno(String itemno) {
this.itemno = itemno;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public void assign(String itemno, String itemname, String suppliername, String warehousingtime, String shipmenttime, String warehousenumber, String warehouseplace, int itemnumber, int outnumber) {
this.itemno = itemno;
this.itemname = itemname;
this.suppliername = suppliername;
this.warehousingtime = warehousingtime;
this.shipmenttime = shipmenttime;
this.warehousenumber = warehousenumber;
this.warehouseplace = warehouseplace;
this.itemnumber = itemnumber;
this.outnumber = outnumber;
}
}
package test;标签:scanner,String,9.17,System,warehouse,println,out From: https://www.cnblogs.com/0608lin/p/17709240.html
import java.util.Scanner;
public class WarehouseManagement {
public static void main(String[] args) {
WarehouseInformation[] warehouses = new WarehouseInformation[5];
Scanner scanner = new Scanner(System.in);
WarehouseInformation warehouse = new WarehouseInformation();
WarehouseInformation warehouse1 = new WarehouseInformation();
WarehouseInformation warehouse2 = new WarehouseInformation();
WarehouseInformation warehouse3 = new WarehouseInformation();
WarehouseInformation warehouse4 = new WarehouseInformation();
warehouse.setItemno("10000000");
warehouse1.setItemno("10000000");
warehouse2.setItemno("10000000");
warehouse3.setItemno("10000000");
warehouse4.setItemno("10000000");
warehouses[0]=warehouse;
warehouses[1]=warehouse;
warehouses[2]=warehouse;
warehouses[3]=warehouse;
warehouses[4]=warehouse;
//主菜单
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品入库管理");
System.out.println(" 2、商品信息修改");
System.out.println(" 3、商品出库管理");
System.out.println(" 4、仓库盘点管理");
System.out.println("***********************************************************");
while(true){
System.out.print("请输入数字选择功能:");
int option = scanner.nextInt();
if (option == 1) {
submit(warehouses, scanner);//调用入库函数
}
else if (option == 2) {
change(warehouses, scanner);//调用修改函数
}
else if (option == 3) {
ship(warehouses, scanner);//调用出库函数
}
else if (option == 4) {
review(warehouses,scanner);//调用盘点函数
}
else {
System.out.println("该选项不存在");
break;
}
}
scanner.close();
}
public static WarehouseInformation findwarehouse(WarehouseInformation[] warehouses, String itemno) {
for (int i = 0; i < warehouses.length; i++) {
if (warehouses[i] != null && warehouses[i].getItemno().equals(itemno)) {
return warehouses[i];
}
}
return null;
}
public static void submit(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (itemno.length()!=8) {
System.out.println("商品编号为8位数字,请重新输入。");
return;
}
System.out.println(" 商品名称:");
String itemname=scanner.next();
System.out.println(" 供货商信息:");
String suppliername=scanner.next();
System.out.println(" 入库时间:");
String warehousingtime=scanner.next();
if (warehousingtime.length()!=8) {
System.out.println("入库时间为8位数字,请重新输入。");
return;
}
System.out.println(" 存放仓库号:");
String warehousenumber=scanner.next();
if (warehousenumber.length()!=3) {
System.out.println("存放仓库号为3位数字,请重新输入。");
return;
}
System.out.println(" 存放位置信息:");
String warehouseplace=scanner.next();
if (warehouseplace.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}
System.out.println(" 入库商品数量:");
int itemnumber=scanner.nextInt();
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 商品编号:"+warehouse.getItemno());
System.out.println(" 商品名称:"+warehouse.getItemname());
System.out.println(" 供货商信息:"+warehouse.getSuppliername());
System.out.println(" 入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 入库商品数量:"+warehouse.getItemnumber());
System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setItemno(itemno);
warehouse.setItemname(itemname);
warehouse.setSuppliername(suppliername);
warehouse.setWarehousingtime(warehousingtime);
warehouse.setWarehousenumber(warehousenumber);
warehouse.setWarehouseplace(warehouseplace);
warehouse.setItemnumber(itemnumber);
System.out.println("提交成功。");
} else {
System.out.println("取消提交。");
}
}
public static void change(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (warehouse == null) {
System.out.println("该商品不存在。");
return;
}
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+warehouse.getItemno());
System.out.println(" 2、商品名称:"+warehouse.getItemname());
System.out.println(" 3、供货商信息:"+warehouse.getSuppliername());
System.out.println(" 4、入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 5、存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 6、存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 7、入库商品数量:"+warehouse.getItemnumber());
System.out.println(" 请选择需要修改的信息编号(1-7):");
System.out.println("***********************************************************");
String itemname=warehouse.getItemname();
String suppliername=warehouse.getSuppliername();
String warehousingtime=warehouse.getWarehousingtime();
String warehousenumber=warehouse.getWarehousenumber();
String warehouseplace=warehouse.getWarehouseplace();
int itemnumber=warehouse.getItemnumber();
while(true){
int option = scanner.nextInt();
if (option == 1) {
System.out.println("请输入修改后的商品编号:");
itemno=scanner.next();
if (itemno.length()!=8) {
System.out.println("商品编号为8位数字,请重新输入。");
return;
}
}
else if (option == 2) {
System.out.println("请输入修改后的商品名称:");
itemname=scanner.next();
}
else if (option == 3) {
System.out.println("请输入修改后的供货商信息:");
suppliername=scanner.next();
}
else if (option == 4) {
System.out.println("请输入修改后的入库时间:");
warehousingtime=scanner.next();
if (warehousingtime.length()!=8) {
System.out.println("入库时间为8位数字,请重新输入。");
return;
}
}
else if (option == 5) {
System.out.println("请输入修改后的存放仓库号:");
warehousenumber=scanner.next();
if (warehousenumber.length()!=8) {
System.out.println("存放仓库号为3位数字,请重新输入。");
return;
}
}
else if (option == 6) {
System.out.println("请输入修改后的存放位置信息:");
warehouseplace=scanner.next();
if (warehouseplace.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}
}
else if (option == 7) {
System.out.println("请输入修改后的商品数量:");
itemnumber=scanner.nextInt();
}
else {
System.out.println("该选项不存在");
break;
}
System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setItemno(itemno);
warehouse.setItemname(itemname);
warehouse.setSuppliername(suppliername);
warehouse.setWarehousingtime(warehousingtime);
warehouse.setWarehousenumber(warehousenumber);
warehouse.setWarehouseplace(warehouseplace);
warehouse.setItemnumber(itemnumber);
System.out.println("提交成功。");
} else {
System.out.println("取消提交。");
}
}
}
public static void ship(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (warehouse == null) {
System.out.println("该商品不存在。");
return;
}
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+warehouse.getItemno());
System.out.println(" 2、商品名称:"+warehouse.getItemname());
System.out.println(" 3、供货商信息:"+warehouse.getSuppliername());
System.out.println(" 4、入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 5、存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 6、存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 7、入库商品数量:"+warehouse.getItemnumber());
System.out.println(" 出库时间:");
String shipmenttime=scanner.next();
if (shipmenttime.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}
System.out.println(" 出库数量:");
int outnumber=scanner.nextInt();
System.out.println("***********************************************************");
System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setShipmenttime(shipmenttime);
warehouse.setOutnumber(outnumber);
System.out.println("提交成功。");
} else {
System.out.println("取消提交。");
}
}
public static void review(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
for(int i=0;i<5;i++){
System.out.println("1、商品编号:"+warehouses[i].getItemno()+"2、商品名称:"+warehouses[i].getItemnumber()+"3、库存数量:"+(warehouses[i].getItemnumber()-warehouses[i].getOutnumber()));
}
}
}