第一部分,设计界面以及类的定义.
import java.util.Scanner; public class viovo { static int number = 5;//五个商品信息 static oppo[] s = new oppo[50]; public static void main(String[] args) { Scanner ab = new Scanner(System.in); for(int i=0;i<s.length;i++) { s[i]=new oppo();//初始化 } while (true) { menu(); int choose = ab.nextInt(); switch (choose) { case 1: input(); break; case 2: change(); break; case 3: output(); break; case 4: pan(); break; } } } public static void menu() {/*主菜单*/ 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("***********************************************************"); } public static void input() {/*商品入库*/ String YN; int i=0; int flag = 0; Scanner sc = new Scanner(System.in); String itemno0=""; //商品编号8 String itemname0=""; //商品名称 String suppliername0=""; //供货商名称 String warehousingtime0=""; //入库时间8 String warehousenumber0=""; //仓库编号3 String warehouseplace0=""; //商品具体位置XXXXYYZZ int itemnumber0=0; //入库商品的数量。 while (true) { System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); Scanner sb=new Scanner(System.in); int fllag=1; while(fllag==1){ System.out.println("请输入商品编号"); itemno0=sb.nextLine(); if(itemno0.length()!=8) System.out.println("格式错误,请输入八位有效数字"); else fllag=0; } System.out.println("请输入商品名称"); itemname0=sb.nextLine(); System.out.println("请输入供货商名称"); suppliername0=sb.nextLine(); int flag1=1; while(flag1==1){ System.out.println("请输入入库时间"); warehousingtime0=sb.nextLine(); if(warehousingtime0.length()!=8) System.out.println("格式错误,请输入八位有效数字"); else flag1=0; } int flag2=1; while(flag2==1){ System.out.println("请输入仓库号"); warehousenumber0=sb.nextLine(); if(warehousenumber0.length()!=3) System.out.println("格式错误,请输入3位有效数字"); else flag2=0; } int flag3=1; while(flag3==1){ System.out.println("请输入商品具体位置"); warehouseplace0=sb.nextLine(); if(warehouseplace0.length()!=8) System.out.println("格式错误,请输入8位有效数字"); else flag3=0; } System.out.println("请输入入库商品的数量"); Scanner ab=new Scanner(System.in); itemnumber0=ab.nextInt(); System.out.println("**********************************************************"); if (flag == 1) { System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 商品编号:" + itemno0); System.out.println(" 商品名称:" + itemname0); System.out.println(" 供货商信息:" + suppliername0); System.out.println(" 入库时间:" + warehousingtime0); System.out.println(" 存放仓库号:" + warehousenumber0); System.out.println(" 存放位置信息:" + warehouseplace0); System.out.println(" 入库商品数量:" + itemnumber0); System.out.println("该商品入库操作已完成,是否提交(Y/N)"); YN = sc.next(); if (YN.equals("Y")) { s[i].setItemno(itemno0); s[i].setItemname(itemname0); s[i].setSuppliername(suppliername0); s[i].setWarehousingtime(warehousingtime0); s[i].setWarehousenumber(warehousenumber0); s[i].setWarehouseplace(warehouseplace0); s[i].setItemnumber(s[i].getItemnumber() + itemnumber0); break; } else { continue; } } else { System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 商品编号:" + itemno0); System.out.println(" 商品名称:" + itemname0); System.out.println(" 供货商信息:" + suppliername0); System.out.println(" 入库时间:" + warehousingtime0); System.out.println(" 存放仓库号:" + warehousenumber0); System.out.println(" 存放位置信息:" + warehouseplace0); System.out.println(" 入库商品数量:" + itemnumber0); System.out.println("该商品入库操作已完成,是否提交(Y/N)"); YN = sc.next(); if (YN.equals("Y")) { s[i].setItemno(itemno0); s[i].setItemname(itemname0); s[i].setSuppliername(suppliername0); s[i].setWarehousingtime(warehousingtime0); s[i].setWarehousenumber(warehousenumber0); s[i].setWarehouseplace(warehouseplace0); s[i].setItemnumber(itemnumber0); number++; break; } else { continue; } } } } public static void change() { Scanner sc = new Scanner(System.in); System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.print("请输入商品编号:"); String itemno1 = sc.next(); System.out.println("**********************************************************"); for (int j = 0; j < s.length; j++) { if (itemno1.equals(s[j].getItemno())) { show(j); System.out.print("请选择需要修改的信息编号(1-7):"); int choose0 = sc.nextInt(); System.out.println("***********************************************************"); if (choose0 < 1 || choose0 > 7) { System.out.println("不存在"); break; } else if (choose0 == 1) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的商品编号:"); String itemno2 = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setItemno(itemno2); else break; } else if (choose0 == 2) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的商品名称:"); String itemname2 = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setItemname(itemname2); else break; } else if (choose0 == 3) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的供货商信息:"); String suppliername2 = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setSuppliername(suppliername2); else break; } else if (choose0 == 4) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的入库时间:"); String warehousingtime2 = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setWarehousingtime(warehousingtime2); else break; } else if (choose0 == 5) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的存放仓库号:"); String wps = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String pp = sc.next(); if (pp.equals("Y")) s[j].setWarehousenumber(wps); else break; } else if (choose0 == 6) { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的存放位置信息:"); String warehouseplace2 = sc.next(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setWarehouseplace(warehouseplace2); else break; } else { show(j); System.out.println("请选择需要修改的信息编号(1-7):" + choose0); System.out.print("请输入修改后的入库商品数量:"); int itemnumber2 = sc.nextInt(); System.out.println("***********************************************************"); System.out.println("Y/N"); String YN1 = sc.next(); if (YN1.equals("Y")) s[j].setItemnumber(itemnumber2); else break; } } else { //System.out.println("没有找到商品"); continue; } } } public static void output() { Scanner sc = new Scanner(System.in); System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.print("请输入商品编号:"); String itemno3 = sc.next(); System.out.println("**********************************************************"); for (int j = 0; j <s.length; j++) { if (itemno3.equals(s[j].getItemno())) { show(j); System.out.print("出库时间:"); String chukutime=sc.next(); System.out.print("出库数量:"); int chukunumber=sc.nextInt(); System.out.println("Y/N"); String YN4= sc.next(); if(YN4.equals("Y")){ s[j].setShipmenttime(chukutime); s[j].setOutnumber(chukunumber); break; } else continue; } else { System.out.println("库中没有该商品"); continue; } } } public static void pan(){ Scanner ab=new Scanner(System.in); System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); for(int i=0;i<number;i++){ System.out.println((i+1)+"商品编号:"+s[i].getItemno()+"商品名称:"+s[i].getItemname()+"库存数量:"+(s[i].getItemnumber()-s[i].getOutnumber())); } } public static void show(int j){ System.out.println("**********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司"); System.out.println(" 仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 1、商品编号:" + s[j].getItemno()); System.out.println(" 2、商品名称:" + s[j].getItemname()); System.out.println(" 3、供货商信息:" + s[j].getSuppliername()); System.out.println(" 4、入库时间:" + s[j].getWarehousingtime()); System.out.println(" 5、存放仓库号:" + s[j].getWarehousenumber()); System.out.println(" 6、存放位置信息:" + s[j].getWarehouseplace()); System.out.println(" 7、入库商品数量:" + s[j].getItemnumber()); } }
public class oppo { private String itemno; //商品编号8 private String itemname; //商品名称 private String suppliername; //供货商名称 private String warehousingtime; //入库时间8 private String shipmenttime; //出库时间8 private String warehousenumber; //仓库编号3 private String warehouseplace; //商品具体位置XXXXYYZZ private int itemnumber; //入库商品的数量。 private int outnumber; //表示出库商品的数量 public oppo(){ } public oppo(String itemno,String itemname,String suppliername,String warehousingtime,String shipmenttime,String warehousenumber,String warehouseplace,int itemnumber,int outnumber) {this.itemno=itemno; this.outnumber=outnumber; this.itemname=itemname; this.itemno=itemno; this.warehousenumber=warehousenumber; this.warehouseplace=warehouseplace; this.warehousingtime=warehousingtime; this.suppliername=suppliername; this.shipmenttime=shipmenttime; this.itemnumber=itemnumber; } public String getItemno() { return itemno; } public void setItemno(String itemno) { this.itemno = itemno; } 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; } }
第二部分设计出库与入库功能
标签:String,rewrite,System,public,println,9.4,sc,classtest,out From: https://www.cnblogs.com/bbbbbeiqu/p/17711625.html