Warehouselnformation.java
package Warehouse; public class WarehouseInformation { private String itemnum; 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 WarehouseInformation(String itemnum, String itemname, String suppliername, String warehousingtime, String shipmenttime, String warehousenumber, String warehouseplace, int itemnumber, int outnumber) { this.itemnum = itemnum; this.itemname = itemname; this.suppliername = suppliername; this.warehousingtime = warehousingtime; this.shipmenttime = shipmenttime; this.warehousenumber = warehousenumber; this.warehouseplace = warehouseplace; this.itemnumber = itemnumber; this.outnumber = outnumber; } public String getItemnum() { return itemnum; } public void setItemnum(String itemnum) { this.itemnum = itemnum; } public String getItemname() { return itemname; } public void setItemname(String itemname) { this.itemname = itemname; } public String getSuppliername() { return suppliername; } public void setSuppliername(String suppliername) { this.suppliername = suppliername; } public String getWarehousingtime() { return warehousingtime; } public void setWarehousingtime(String warehousingtime) { this.warehousingtime = warehousingtime; } public String getShipmenttime() { return shipmenttime; } public void setShipmenttime(String shipmenttime) { this.shipmenttime = shipmenttime; } public String getWarehousenumber() { return warehousenumber; } public void setWarehousenumber(String warehousenumber) { this.warehousenumber = warehousenumber; } public String getWarehouseplace() { return warehouseplace; } public void setWarehouseplace(String warehouseplace) { this.warehouseplace = warehouseplace; } public int getItemnumber() { return itemnumber; } public void setItemnumber(int itemnumber) { this.itemnumber = itemnumber; } public int getOutnumber() { return outnumber; } public void setOutnumber(int outnumber) { this.outnumber = outnumber; } }
WarhouseManagement2.java
package Warehouse; import java.util.Scanner; import java.util.ArrayList; public class WarhouseManagement2 { private ArrayList<WarehouseInformation> list=new ArrayList<>(); public void mainFrame( )//主界面方法 { Scanner sc = new Scanner(System.in); while (true) { String st = """ *********************************************************** 石家庄铁道大学前进22软件开发有限公司 仓库管理系统2022版 ********************************************************** """; System.out.println(st); System.out.println(" 1、商品入库管理"); System.out.println(" 2、商品信息修改"); System.out.println(" 3、商品出库管理"); System.out.println(" 4、仓库盘点管理"); System.out.println("***********************************************************"); int choice = sc.nextInt(); switch(choice) { case 1-> goodsWarehousing(); case 2->modifyWarehouse (); case 3->outboundWarehouse (); case 4->countGoods(); default -> { System.out.println("输入错误,请重试"); } } } } public void total() { String st = """ *********************************************************** 石家庄铁道大学前进22软件开发有限公司 仓库管理系统2022版 ********************************************************** """; System.out.println(st); System.out.println("***********************************************************"); System.out.println(" 请输入商品编号:XXXXXXXX"); System.out.println("***********************************************************"); } public void goodsWarehousing()//商品入库方法 { Scanner sc=new Scanner(System.in); String s1; String s2; String s3; String s4; String s5; String s6; int h; System.out.println("请输入8位商品编号:"); s1 = sc.next(); s1=Check(s1,8); System.out.println("请输入商品名称:"); s2 = sc.next(); System.out.println("请输入商品的供货商信息:"); s3 = sc.next(); System.out.println("请输入8位入库时间"); s4 = sc.next(); s2=Check(s2,8); System.out.println("请输入存放3位仓库号:"); s5 = sc.next(); s5=Check(s5,3); System.out.println("请输入8位存放位置信息:"); s6 = sc.next(); s6=Check(s6,8); System.out.println("请输入入库商品数量:"); h = sc.nextInt(); System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 商品编号:" + s1); System.out.println(" 商品名称:" + s2); System.out.println(" 供货商信息:" + s3); System.out.println(" 入库时间:" + s4); System.out.println(" 存放仓库号:" + s5); System.out.println(" 存放位置信息:" + s6); System.out.println(" 入库商品数量:" + h); System.out.println(" 该商品入库操作已完成,是否提交(Y/N)"); System.out.println("***********************************************************"); String s = sc.next(); if (s.equals("Y")) { WarehouseInformation ware = new WarehouseInformation(s1, s2, s3, s4, " ", s5, s6, h, 0); System.out.println("提交成功"); list.add(ware); } else { System.out.println("提交失败"); } } public void modifyWarehouse ()//商品修改方法 { Scanner sc=new Scanner(System.in); total(); String str = sc.next(); for (int i = 0; i <= list.size(); i++) { int f = 1; if (str.equals(list.get(i).getItemnum())) { f = 0; System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 1.商品编号:" + list.get(i).getItemnum()); System.out.println(" 2.商品名称:" + list.get(i).getItemname()); System.out.println(" 3.供货商信息:" + list.get(i).getSuppliername()); System.out.println(" 4.入库时间:" + list.get(i).getWarehousingtime()); System.out.println(" 5.存放仓库号:" + list.get(i).getWarehousenumber()); System.out.println(" 6.存放位置信息:" + list.get(i).getWarehouseplace()); System.out.println(" 7.入库商品数量:" + list.get(i).getItemnumber()); System.out.println(" 请选择需要修改的信息编号(1-7):"); System.out.println("***********************************************************"); int k = sc.nextInt(); System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 1.商品编号:" + list.get(i).getItemnum()); System.out.println(" 2.商品名称:" + list.get(i).getItemname()); System.out.println(" 3.供货商信息:" + list.get(i).getSuppliername()); System.out.println(" 4.入库时间:" + list.get(i).getWarehousingtime()); System.out.println(" 5.存放仓库号:" + list.get(i).getWarehousenumber()); System.out.println(" 6.存放位置信息:" + list.get(i).getWarehouseplace()); System.out.println(" 7.入库商品数量:" + list.get(i).getItemnumber()); if (k == 1) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的商品编号:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setItemnum(sr); } if (f == 1) { System.out.println("库中不存在该商品信息"); } } if (k == 2) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的商品名称:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setItemname(sr); } } if (k == 3) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的供货商信息:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setSuppliername(sr); } } if (k == 4) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的入库时间:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setWarehousenumber(sr); } } if (k == 5) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的仓库号:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setWarehousenumber(sr); } } if (k == 6) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的存放位置信息:XXXXXXXX"); System.out.println("***********************************************************"); String sr = sc.next(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setWarehouseplace(sr); } } if (k == 7) { System.out.println(" 请选择需要修改的信息编号(1-7):" + k); System.out.println(" 请输入修改后的入库商品数量:XXXXXXXX"); System.out.println("***********************************************************"); int p = sc.nextInt(); System.out.println("请确认(Y/N)"); String sd = sc.next(); if (sd.equals("Y")) { list.get(i).setItemnumber(p); } } if ((k != 1) && (k != 2) && (k != 3) && (k != 4) && (k != 5) && (k != 6) && (k != 7)) { System.out.println("该选项不存在"); } } } } public void outboundWarehouse ()//商品出库方法 { total(); Scanner sc=new Scanner(System.in); String str = sc.next(); for (WarehouseInformation wfInfo : list) { int t = 1; if (str.equals(wfInfo.getItemnum())) { t = 0; System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 1.商品编号:" + wfInfo.getItemnum()); System.out.println(" 2.商品名称:" + wfInfo.getItemname()); System.out.println(" 3.供货商信息:" + wfInfo.getSuppliername()); System.out.println(" 4.入库时间:" + wfInfo.getWarehousingtime()); System.out.println(" 5.存放仓库号:" + wfInfo.getWarehousenumber()); System.out.println(" 6.存放位置信息:" +wfInfo.getWarehouseplace()); System.out.println(" 7.入库商品数量:" + wfInfo.getItemnumber()); System.out.println(" 出库时间:XXXXXXXXX"); System.out.println(" 出库数量:xxx"); System.out.println("***********************************************************"); String str1 = sc.next(); int jh = sc.nextInt(); int num = 0; for (WarehouseInformation wfInfo1 : list) { if (wfInfo1.getItemnum().equals(str)) { num += wfInfo1.getItemnumber(); } } if (num < jh) { System.out.println("出库数量大于库中存量"); } else { System.out.println(num); System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 1.商品编号:" + wfInfo.getItemnum()); System.out.println(" 2.商品名称:" + wfInfo.getItemname()); System.out.println(" 3.供货商信息:" + wfInfo.getSuppliername()); System.out.println(" 4.入库时间:" + wfInfo.getWarehousingtime()); System.out.println(" 5.存放仓库号:" + wfInfo.getWarehousenumber()); System.out.println(" 6.存放位置信息:" + wfInfo.getWarehouseplace()); System.out.println(" 7.入库商品数量:" + wfInfo.getItemnumber()); System.out.println(" 出库时间:" + str1); System.out.println(" 出库数量:" + jh); System.out.println(" 该商品入库操作已完成,是否提交(Y/N)"); System.out.println("***********************************************************"); String sd = sc.next(); if (sd.equals("Y")) { wfInfo.setShipmenttime(str1); wfInfo.setOutnumber(jh); } } if (t == 1) { System.out.println("库中不存在该商品信息"); } } } } public void countGoods()//商品统计数量方法 { System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); for (WarehouseInformation wfInfo2 : list) { int num=0; for(WarehouseInformation wfInfo3:list) { if(wfInfo2.getItemnum().equals(wfInfo3.getItemnum())) { num=wfInfo3.getItemnumber()-wfInfo3.getOutnumber(); } } System.out.println("库存数量:" + num); System.out.print("商品编号" + wfInfo2.getItemnum() + " "); System.out.print("商品名称" + wfInfo2.getItemname() + " "); } System.out.println("***********************************************************"); } public String Check(String str,int n) { Scanner sc=new Scanner(System.in); String s=str; while(true) { if(s.length()!=n) { System.out.println("输入不符合要求,请重新输入"); s=sc.next(); } else { return s; } } } }
Main.java
package Warehouse; public class Main { public static void main(String[] args) { WarhouseManagement2 warehouse=new WarhouseManagement2(); warehouse.mainFrame(); } }
标签:String,void,修正,System,测试,println,public,out From: https://www.cnblogs.com/binglinll/p/17707121.html