9.11 开学考试规范写
1.开学考试规范写
package kaixuekaoshi1; //班级:2205-2 // 学号:20224082 // 姓名:艾鑫 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 int getItemnumber() { return itemnumber; } public String getItemname() { return itemname; } public String getItemno() { return itemno; } public String getWarehousenumber() { return warehousenumber; } public String getWarehouseplace() { return warehouseplace; } public int getOutnumber() { return outnumber; } public String getShipmenttime() { return shipmenttime; } public String getSuppliername() { return suppliername; } public String getWarehousingtime() { return warehousingtime; } public void setItemno(String itemno) { this.itemno = itemno; } public void setItemname(String itemname) { this.itemname = itemname; } public void setItemnumber(int itemnumber) { this.itemnumber = itemnumber; } public void setOutnumber(int outnumber) { this.outnumber = outnumber; } public void setShipmenttime(String shipmenttime) { this.shipmenttime = shipmenttime; } public void setSuppliername(String suppliername) { this.suppliername = suppliername; } public void setWarehousenumber(String warehousenumber) { this.warehousenumber = warehousenumber; } public void setWarehouseplace(String warehouseplace) { this.warehouseplace = warehouseplace; } public void setWarehousingtime(String warehousingtime) { this.warehousingtime = warehousingtime; } public WarehouseInformation(){ } public WarehouseInformation(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.itemnumber=itemnumber; this.outnumber=outnumber; this.shipmenttime=shipmenttime; this.suppliername=suppliername; this.warehousingtime=warehousingtime; this.warehousenumber=warehousenumber; this.warehouseplace=warehouseplace; } public void sett(String itemno,String itemname,String suppliername,String warehousingtime ,String warehousenumber,String warehouseplace,int itemnumber) { this.itemno=itemno; this.itemname=itemname; this.itemnumber=itemnumber; this.suppliername=suppliername; this.warehousingtime=warehousingtime; this.warehousenumber=warehousenumber; this.warehouseplace=warehouseplace; } }
package kaixuekaoshi1; import java.time.LocalDate; import java.util.Scanner; public class WarehouseManagement { static Scanner sc=new Scanner(System.in); static int N; static WarehouseInformation []s=new WarehouseInformation[100]; public static void chushi(){ s[0]=new WarehouseInformation(); s[0].sett("20203982","华为笔记本电脑","河北省正大光明有限公司","20230904","003","01803500",100); s[1]=new WarehouseInformation(); s[1].sett("20203983","xx笔记本电脑","河北省yui有限公司","20230906","004","01803400",190); s[2]=new WarehouseInformation(); s[2].sett("20203984","zz笔记本电脑","河北省gho有限公司","20230907","005","01803600",168); s[3]=new WarehouseInformation(); s[3].sett("20203985","ww笔记本电脑","河北省ghj有限公司","20230909","006","01803800",145); s[4]=new WarehouseInformation(); s[4].sett("20203986","kk笔记本电脑","河北省dfh有限公司","20230908","007","01803900",78); N=5; } public static void show(){ 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("**********************************************************"); int n=sc.nextInt(); if(n==1) submit(); else if(n==2) change(); else if(n==3) out(); else if(n==4) inventory(); else System.out.println("该选项不存在"); } public static void submit(){ while(true){ int t=0; System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println("请输入商品编号:"); String str1= sc.next(); s[N]=new WarehouseInformation(); s[N].setItemno(str1); if(str1.length()==8){ System.out.println("请输入商品名称 :"); s[N].setItemname(sc.next()); System.out.println("请输入供货商信息 :"); s[N].setSuppliername(sc.next()); System.out.println("请输入入库时间 :"); String str2=sc.next(); if(str2.length()==8){ s[N].setWarehousingtime(str2); System.out.println("请输入仓库号:"); String str3=sc.next(); if(str3.length()==3){ s[N].setWarehousenumber(str3); System.out.println("请输入存放位置信息:"); String str4=sc.next(); if(str4.length()==8){ s[N].setWarehouseplace(str4); System.out.println("请输入入库商品数量:"); s[N].setItemnumber(sc.nextInt()); System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.printf(" 商品编号:%s\n",s[N].getItemno()); System.out.printf(" 商品名称:%s\n",s[N].getItemname()); System.out.printf(" 供货商信息:%s\n",s[N].getSuppliername() ); System.out.printf(" 入库时间:%s\n",s[N].getWarehousingtime() ); System.out.printf(" 存放仓库号:%s\n",s[N].getWarehousenumber()); System.out.printf(" 存放位置信息:%s\n",s[N].getWarehouseplace()); System.out.printf(" 入库商品数量:%d\n",s[N].getItemnumber()); System.out.println(" 该商品入库操作已完成,是否提交(Y/N)"); System.out.println("**********************************************************"); N++; String chose1=sc.next(); if(chose1.equals("Y")){ t=1; } else{ t=0; N--; s[N].setItemno(" "); s[N].setItemname(" "); s[N].setSuppliername(" "); s[N].setWarehousingtime(" "); s[N].setWarehouseplace(" "); s[N].setWarehousenumber(" "); s[N].setItemnumber(0); } } else System.out.println("录入错误"); } else System.out.println("录入错误"); } else System.out.println("录入错误"); } else { System.out.println("录入错误"); } if(t==1) break; } } public static void change(){ while(true){ int t=0; System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 请输入商品编号:XXXXXXXX"); System.out.println("**********************************************************"); System.out.println(" 商品编号八位数"); String id=sc.next(); for(int i=0;i<N;i++){ if(id.equals(s[i].getItemno())){ System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.printf(" 1商品编号:%s\n",s[i].getItemno()); System.out.printf(" 2商品名称:%s\n",s[i].getItemname()); System.out.printf(" 3供货商信息:%s\n",s[i].getSuppliername() ); System.out.printf(" 4入库时间:%s\n",s[i].getWarehousingtime() ); System.out.printf(" 5 存放仓库号:%s\n",s[i].getWarehousenumber()); System.out.printf(" 6存放位置信息:%s\n",s[i].getWarehouseplace()); System.out.printf(" 7入库商品数量:%d\n",s[i].getItemnumber()); System.out.println(" 请选择需要修改的信息编号(1-7):"); System.out.println("**********************************************************"); String x1=s[i].getItemno(),x2=s[i].getItemname(),x3=s[i].getSuppliername(); String x4=s[i].getWarehousingtime(),x5=s[i].getWarehousenumber(),x6=s[i].getWarehouseplace(); int x7=s[i].getItemnumber(); int chose2=sc.nextInt(); if(chose2<1||chose2>7) { System.out.println("该选项不存在"); } else { System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.printf(" 1商品编号:%s\n",s[i].getItemno()); System.out.printf(" 2商品名称:%s\n",s[i].getItemname()); System.out.printf(" 3供货商信息:%s\n",s[i].getSuppliername() ); System.out.printf(" 4入库时间:%s\n",s[i].getWarehousingtime() ); System.out.printf(" 5 存放仓库号:%s\n",s[i].getWarehousenumber()); System.out.printf(" 6存放位置信息:%s\n",s[i].getWarehouseplace()); System.out.printf(" 7入库商品数量:%d\n",s[i].getItemnumber()); System.out.printf(" 请选择需要修改的信息编号(1-7):%d\n",chose2); switch (chose2) { case 1: { System.out.println(" 请输入修改后的商品编号:XXXXXXXX"); System.out.println("**********************************************************"); s[i].setItemno(sc.next()); break; } case 2: { System.out.println(" 请输入修改后的商品名称:XXXXXXXX"); System.out.println("**********************************************************"); s[i].setItemname(sc.next()); break; } case 3: { System.out.println(" 请输入修改后的供货商信息 :XXXXXXXX"); System.out.println("**********************************************************"); s[i].setSuppliername(sc.next()); break; } case 4: { System.out.println(" 请输入修改后的入库时间 :XXXXXXXX"); System.out.println("**********************************************************"); s[i].setWarehousingtime(sc.next()); break; } case 5: { System.out.println(" 请输入修改后的存放仓库号 :XXXXXXXX"); System.out.println("**********************************************************"); s[i].setWarehousenumber(sc.next()); break; } case 6: { System.out.println(" 请输入修改后的存放位置信息 :XXXXXXXX"); System.out.println("**********************************************************"); s[i].setWarehouseplace (sc.next()); break; } case 7: { System.out.println(" 请输入修改后的入库商品数量 :XXXXXXXX"); System.out.println("**********************************************************"); s[i].setItemnumber (sc.nextInt()); break; } } System.out.println(" 该商品商品信息修改已完成,是否提交(Y/N)"); System.out.println(" Y 保存 N 不保存"); String chose3=sc.next(); if(chose3.equals("Y")){ t=1; break; } else{ t=0; s[i].setItemno(x1); s[i].setItemname(x2); s[i].setSuppliername(x3); s[i].setWarehousingtime(x4); s[i].setWarehousenumber(x5); s[i].setWarehouseplace (x6); s[i].setItemnumber (x7); break; } } } else if(i==N-1){ t=0; System.out.println("库中没有该商品"); break; } } if(t==1) break; } } public static void out(){ while(true){ int t=0; System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.println(" 请输入商品编号:XXXXXXXX"); System.out.println("**********************************************************"); System.out.println(" 商品编号八位数"); String id=sc.next(); for(int i=0;i<N;i++){ if(id.equals(s[i].getItemno())) { System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); System.out.printf(" 1商品编号:%s\n", s[i].getItemno()); System.out.printf(" 2商品名称:%s\n", s[i].getItemname()); System.out.printf(" 3供货商信息:%s\n", s[i].getSuppliername()); System.out.printf(" 4入库时间:%s\n", s[i].getWarehousingtime()); System.out.printf(" 5 存放仓库号:%s\n", s[i].getWarehousenumber()); System.out.printf(" 6存放位置信息:%s\n", s[i].getWarehouseplace()); System.out.printf(" 7入库商品数量:%d\n", s[i].getItemnumber()); System.out.println(" 出库时间:XXXXXXXXX"); System.out.println(" 出库数量:xxx"); System.out.println("**********************************************************"); String chushi = sc.next(); Integer num = Integer.parseInt(chushi); Integer num1=Integer.parseInt(s[i].getWarehousingtime()); int day1=num1%100; int month1=num%1000/100; int year1=num-month1; int day2 = num % 100; int month2 = num % 10000 / 100; int year2 = num - month2; LocalDate date1=LocalDate.of( year1, month1,day1); LocalDate date2=LocalDate.of(year2,month2,day2); int ss=date1.compareTo(date2); if(month2>=1&&month2<=12&&day2>=1&&day2<=31&&ss!=0){ int chu = sc.nextInt(); if (chu <= s[i].getItemnumber()) { s[i].setOutnumber(chu); s[i].setShipmenttime(chushi); System.out.println(" 该商品出库已完成,是否提交(Y/N)"); System.out.println(" Y 保存 N 不保存"); String chose3 = sc.next(); if (chose3.equals("Y")) { t = 1; break; } else { t = 0; s[i].setOutnumber(0); s[i].setShipmenttime(" "); break; } } else { System.out.println("输入错误,没有这么多库存"); t = 0; break; } } else{ System.out.println("时间不对"); t=0; break; } } else if(i==N-1){ t=0; System.out.println("库中没有该商品"); break; } } if(t==1) break; } } public static void inventory(){ System.out.println("***********************************************************"); System.out.println(" 石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版"); System.out.println("***********************************************************"); for(int i=0;i<N;i++){ System.out.printf("1、商品编号:%s、商品名称:%s、库存数量:%d\n",s[i].getItemno(),s[i].getItemname(),s[i].getItemnumber()-s[i].getOutnumber()); } System.out.println("**********************************************************"); } public static void main(String[] args) { chushi(); while(true){ show(); } } }