考试代码

package 拉倒吧;
import java.util.Scanner;


public class WarehouseInformation {
String itemno;//编号
String itemname;//商品名称
String suppliername;//供货商名称
String warehousingtime;//入库时间
String shipmenttime;//出库时间
String warehousenumber;//仓库编号
String warehouseplace;//具体位置
int itemnumber;//入库数量
int outnumber;//出库数量
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.suppliername=suppliername;
this.warehousingtime=warehousingtime;
this.shipmenttime=shipmenttime;
this.warehousenumber=warehousenumber;
this.warehouseplace=warehouseplace;
this.itemnumber=itemnumber;
this.outnumber=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 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 static void menu1() {
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 main(String [] args)
{
Scanner scanner=new Scanner(System.in);

//建立数组
WarehouseInformation[] a = new WarehouseInformation[5];
a[0]=new WarehouseInformation("20203982","华为笔记本电脑1","河北省正大光明有限公司1","20230904","0","003","0180251",100,0);
a[1]=new WarehouseInformation("20203983","华为笔记本电脑2","河北省正大光明有限公司2","20230905","0","004","0180252",101,0);
a[2]=new WarehouseInformation("20203984","华为笔记本电脑3","河北省正大光明有限公司3","20230906","0","005","0180253",102,0);
a[3]=new WarehouseInformation("20203985","华为笔记本电脑4","河北省正大光明有限公司4","20230907","0","006","0180254",103,0);
a[4]=new WarehouseInformation("20203986","华为笔记本电脑5","河北省正大光明有限公司5","20230908","0","007","0180255",104,0);


menu1();
while(true)
{


int n=scanner.nextInt();

switch(n) {
case 1:
f1(a);
break;
case 2:
f2(a);
break;
case 3:
f3(a);
break;
case 4:
f4(a);
break;
default:
System.out.println("该选项不存在,请重新选择");
break;
}


}

}


public static void f1(WarehouseInformation [] a) {
while(true) {

boolean f=true;
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 选择存入第几位商品(1~5)");
System.out.println(" 请依次录入商品编码、商品名称、供货商信息、入库时间、存放仓库号、存放位置信息、入库商品数量");
System.out.println("***********************************************************");
Scanner scanner=new Scanner(System.in);

int n=scanner.nextInt();
String no=scanner.nextLine();//编码
String name=scanner.nextLine();//商品名称
String suppliername=scanner.nextLine();//供货商名称
String warehousingtime=scanner.nextLine();//入库时间
String warehousenumber=scanner.nextLine();//存放仓库号
String warehouseplace=scanner.nextLine();//存放位置信息
int itemnumber=scanner.nextInt();//入库数量

//判断录入格式错误

//if(no.length()!=8) {
//f=false;
//System.out.println("无效输入,请重新输入");
//}


if(f) {
while(true)
{
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 商品编号:"+no);
System.out.println(" 商品名称:"+name);
System.out.println(" 供货商信息:"+suppliername);
System.out.println(" 入库时间:"+warehousingtime);
System.out.println(" 存放仓库号:"+warehousenumber);
System.out.println(" 存放位置信息:"+warehouseplace);
System.out.println(" 入库商品数量:"+itemnumber);
System.out.println(" 该商品入库操作已完成,是否提交(Y/N)");

Scanner q=new Scanner(System.in);
char b = scanner.next().charAt(0);


if(b=='Y') {
a[n-1].setitemno(no);
a[n-1].setitemname(name);
a[n-1].setsuppliername(suppliername);
a[n-1].setwarehousingtime(warehousingtime);
a[n-1].setwarehousenumber(warehousenumber);
a[n-1].setwarehouseplace(warehouseplace);
a[n-1].setitemnumber(itemnumber);
break;
}

if(b=='N') {

}

break;

}

}


}
}

public static void f2(WarehouseInformation [] a) {

while(true) {

System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
System.out.println("***********************************************************");

Scanner scanner=new Scanner(System.in);
String itemname=scanner.nextLine();
boolean f=false;
int j=0;

for(int i=0;i<5;i++)
{
if (a[i].itemname.equals(itemname)) {
f=true;
j=i;
break;
}
}

if(f) {
while(true) {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+a[j].itemno);
System.out.println(" 2、商品名称:"+a[j].itemname);
System.out.println(" 3、供货商信息:"+a[j].suppliername);
System.out.println(" 4、入库时间:"+a[j].warehousingtime);
System.out.println(" 5、存放仓库号:"+a[j].warehousenumber);
System.out.println(" 6、存放位置信息:"+a[j].warehouseplace);
System.out.println(" 7、入库商品数量:"+a[j].itemnumber);
System.out.println(" 请选择需要修改的信息编号(1-7):");
System.out.println("***********************************************************");

int n=scanner.nextInt();

switch(n) {
case 1:
String itemno=scanner.nextLine();
a[j].setitemno(itemno);
break;
case 2:
String name=scanner.nextLine();
a[j].setitemno(name);
break;
case 3:
String suppliername=scanner.nextLine();
a[j].setitemno(suppliername);
break;
case 4:
String warehousingtime=scanner.nextLine();
a[j].setitemno(warehousingtime);
break;
case 5:
String warehousenumber=scanner.nextLine();
a[j].setitemno(warehousenumber);
break;
case 6:
String warehouseplace=scanner.nextLine();
a[j].setitemno(warehouseplace);
break;
case 7:
String itemnumber=scanner.nextLine();
a[j].setitemno(itemnumber);
break;
default:
System.out.println("该选项不存在,请重新选择");
break;
}

break;
}
break;
}

if(!f) {
System.out.println("库中没有该商品");
}


}

}

public static void f3(WarehouseInformation [] a) {



while(true)
{
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
System.out.println("***********************************************************");

Scanner scanner=new Scanner(System.in);
String itemno=scanner.nextLine();
boolean f=false;
int j=0;

for(int i=0;i<5;i++)
{
if (a[i].itemno.equals(itemno)) {
f=true;
j=i;
break;
}
}

if(f==false) {
System.out.println("没有该商品");
}


if(f)
{

while(true)
{
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+a[j].itemno);
System.out.println(" 2、商品名称:"+a[j].itemname);
System.out.println(" 3、供货商信息:"+a[j].suppliername);
System.out.println(" 4、入库时间:"+a[j].warehousingtime);
System.out.println(" 5、存放仓库号:"+a[j].warehousenumber);
System.out.println(" 6、存放位置信息:"+a[j].warehouseplace);
System.out.println(" 7、入库商品数量:"+a[j].itemnumber);
System.out.println(" 出库时间:");
System.out.println(" 出库商品数量:");

String s2=scanner.nextLine();
int s=scanner.nextInt();
int b=a[j].itemnumber=a[j].itemnumber-s;

if(b<0)
{

}

if(b>=0)
{
System.out.println("是否保存结果(Y/N)");
char d = scanner.next().charAt(0);

if(d=='Y')
{
a[j].setshipmenttime(s2);
a[j].setoutnumber(s);
break;
}

if(d=='N')
{

}
}
}
}

}
}

public static void f4(WarehouseInformation [] a) {

System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
for(int i=0;i<5;i++) {
System.out.println((i+1)+"、商品编号:"+a[i].getitemno()+"、商品名称:"+a[i].getitemname()+"、库存数量"+(a[i].getitemnumber()-a[i].getoutnumber()));
}

System.out.println("***********************************************************");
}



}

 

posted @ 2023-09-16 21:04  财神给你送元宝  阅读(9)  评论(0编辑  收藏  举报