WarehouseInformation系统的增删改查操作
一、
实现WarehouseInformation类中的成员变量,赋值函数等;
代码如下:
public class WarehouseInformation {
private String itemno; //表示商品编号(有8 位数字组成)
private String itemname; //表示商品名称
private String suppliername; //表示供货商名称
private String warehousingtime; //表示入库时间,长度八位例如:20230904
private String shipmenttime; //表示出库时间,长度八位例如:20230904
private String warehousenumber; //表示仓库编号。长度三位。
private String warehouseplace; //表示存放商品的具体位置,长度八位数字XXXXYYZZ,其中XXXX表示货架号,YY表示货架的层号,ZZ表示存放在该货架该层的商品顺序号
private int itemnumber; //表示入库商品的数量。
private int outnumber; //表示出库商品的数量
private int kucun;
public void setItemno(String itemno)
{
this.itemno=itemno;
}
public String getItemno() {
return itemno;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public String getItemname() {
return itemname;
}
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
public String getSuppliername() {
return suppliername;
}
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
public String getWarehousingtime()
{
return warehousingtime;
}
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
public String getShipmenttime() {
return shipmenttime;
}
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
public String getWarehousenumber() {
return warehousenumber;
}
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
public String getWarehouseplace() {
return warehouseplace;
}
public void setIntemnumber(int intemnumber) {
this.itemnumber = intemnumber;
}
public int getIntemnumber() {
return itemnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public int getOutnumber() {
return outnumber;
}
public void setKucun(int kucun) {
this.kucun = this.itemnumber-this.outnumber;
}
public int getKucun() {
return this.itemnumber-this.outnumber;
}
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.suppliername=suppliername;
this.warehousingtime=warehousingtime;
this.shipmenttime=shipmenttime;
this.warehousenumber=warehousenumber;
this.warehouseplace=warehouseplace;
this.itemnumber=itemnumber;
this.outnumber=outnumber;
}
二、
实现管理类WarehouseManagement,包括赋值函数,菜单,增删改查等操作函数
赋初始值:
public static void fuzhi()
{
String no="20220000";
String name="aa";
String supname="geiaa";
String housingtime="20220101";
String shiptime="20230101";
String housenumber="001";
String houseplace="00000001";
int itemnum=10;
int outnum=2;
a[0]=new WarehouseInformation(no,name,supname,housingtime,shiptime,housenumber,houseplace,itemnum,outnum);
no="20220001";
name="bb";
supname="geibb";
housingtime="20220102";
shiptime="20230102";
housenumber="002";
houseplace="00000002";
itemnum=10;
outnum=2;
a[1]=new WarehouseInformation(no,name,supname,housingtime,shiptime,housenumber,houseplace,itemnum,outnum);
no="20220003";
name="cc";
supname="geicc";
housingtime="20220103";
shiptime="20230103";
housenumber="003";
houseplace="00000003";
itemnum=10;
outnum=2;
a[2]=new WarehouseInformation(no,name,supname,housingtime,shiptime,housenumber,houseplace,itemnum,outnum);
no="20220004";
name="dd";
supname="geidd";
housingtime="20220104";
shiptime="20230104";
housenumber="004";
houseplace="00000004";
itemnum=10;
outnum=2;
a[3]=new WarehouseInformation(no,name,supname,housingtime,shiptime,housenumber,houseplace,itemnum,outnum);
no="20220005";
name="ee";
supname="geiee";
housingtime="20220105";
shiptime="20230105";
housenumber="005";
houseplace="00000005";
itemnum=10;
outnum=2;
a[4]=new WarehouseInformation(no,name,supname,housingtime,shiptime,housenumber,houseplace,itemnum,outnum);
sum=5;
}
菜单:
public static void caidan()
{
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("**********************************************************");
System.out.println("请输入:");
}
public static void caidan1()
{
System.out.println("***********************************************************");
System.out.println("石家庄铁道大学前进22软件开发有限公司");
System.out.println("仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("请输入商品编号:XXXXXXXX");
System.out.println("**********************************************************");
}
增删改查操作:
public static void ruku()
{
System.out.println("请按对应指示输入内容:");
System.out.printf("商品编号:");
Scanner sc=new Scanner(System.in);
String no=sc.nextLine();
System.out.printf("\n");
if(no.length()!=8)
{
System.out.println("您的输入有误!");
caidan();
}
System.out.printf("商品名称:");
String name=sc.nextLine();
System.out.printf("\n");
System.out.printf("供货商信息:");
String supname=sc.nextLine();
System.out.printf("\n");
System.out.printf("入库时间:");
String housingtime=sc.nextLine();
System.out.printf("\n");
if(housingtime.length()!=8)
{
System.out.println("您的输入有误!");
caidan();
}
System.out.printf("存放仓库号:");
String housenumber=sc.nextLine();
System.out.printf("\n");
if(housenumber.length()!=3)
{
System.out.println("您的输入有误!");
caidan();
}
System.out.printf("存放位置信息:");
String houseplace=sc.nextLine();
System.out.printf("\n");
if(houseplace.length()!=8)
{
System.out.println("您的输入有误!");
caidan();
}
System.out.printf("入库商品数量:");
int itemnum=sc.nextInt();
System.out.printf("\n");
System.out.println("该商品入库操作已完成,是否提交(Y/N)");
caidan();
}
public static void xiugai()
{
System.out.println("请输入商品编号:");
Scanner sc=new Scanner(System.in);
String ch=sc.nextLine();
if(ch.length()==8)
{
for(int i=0;i<5;i++)
{
if(a[i].getItemno().equals(ch))
{
System.out.println("1、商品编号:"+a[i].getItemno());
System.out.println("2、商品名称:"+a[i].getItemname());
System.out.println("3、供货商信息:"+a[i].getSuppliername());
System.out.println("4、入库时间:"+a[i].getWarehousingtime());
System.out.println("5、存放仓库号:"+a[i].getWarehousenumber());
System.out.println("6、存放位置信息:"+a[i].getWarehouseplace());
System.out.println("7、入库商品数量:"+a[i].getIntemnumber());
System.out.println("请选择需要修改的信息编号(1-7):");
Scanner bh=new Scanner(System.in);
int c=bh.nextInt();
switch(c)
{
case 1 :
System.out.println("请输入修改后的编码:");
String no= sc.nextLine();
String m=sc.nextLine();
if(m.equals("Y"))
{
a[i].setItemno(no);
}
else if(m.equals("N"))
{
caidan();
}
break;
case 2 :
System.out.println("请输入修改后的商品名称:");
String name= sc.nextLine();
String p=sc.nextLine();
if(p.equals("Y"))
{
a[i].setItemname(name);
}
else if(p.equals("N"))
{
caidan();
}
break;
case 3 :
System.out.println("请输入修改后的供货商信息:");
String supname= sc.nextLine();
String k=sc.nextLine();
if(k.equals("Y"))
{
a[i].setSuppliername(supname);
}
else if(k.equals("N"))
{
caidan();
}
break;
case 4 :
System.out.println("请输入修改后的入库时间:");
String housingtime= sc.nextLine();
String u=sc.nextLine();
if(u.equals("Y"))
{
a[i].setWarehousingtime(housingtime);
}
else if(u.equals("N"))
{
caidan();
}
break;
case 5 :
System.out.println("请输入修改后的存放仓库号:");
String housenumber= sc.nextLine();
String l=sc.nextLine();
if(l.equals("Y"))
{
a[i].setWarehousenumber(housenumber);
}
else if(l.equals("N"))
{
caidan();
}
break;
case 6 :
System.out.println("请输入修改后的存放位置信息:");
String houseplace= sc.nextLine();
String h=sc.nextLine();
if(h.equals("Y"))
{
a[i].setWarehouseplace(houseplace);
}
else if(h.equals("N"))
{
caidan();
}
break;
case 7 :
System.out.println("请输入修改后的入库商品数量:");
int itemnum=sc.nextInt();
String g=sc.next();
if(g.equals("Y"))
{
a[i].setIntemnumber(itemnum);
}
else if(g.equals("N"))
{
caidan();
}
break;
default:
System.out.println("您输入的数字错误!");
caidan();
break;
}
break;
}
else
{
System.out.println("没有该商品!");
caidan();
}
}
}
else
{
System.out.println("输入的商品编码有误!");
caidan1();
}
}
public static void chuku()
{
System.out.println("请输入商品编号:");
Scanner sc=new Scanner(System.in);
String ch=sc.nextLine();
if(ch.length()==8)
{
for(int i=0;i<5;i++)
{
if(ch.compareTo(a[i].getItemno())==0)
{
System.out.println("1、商品编号:"+a[i].getItemno());
System.out.println("2、商品名称:"+a[i].getItemname());
System.out.println("3、供货商信息:"+a[i].getSuppliername());
System.out.println("4、入库时间:"+a[i].getWarehousingtime());
System.out.println("5、存放仓库号:"+a[i].getWarehousenumber());
System.out.println("6、存放位置信息:"+a[i].getWarehouseplace());
System.out.println("7、入库商品数量:"+a[i].getIntemnumber());
Scanner ck=new Scanner(System.in);
String shiptime=ck.nextLine();
int outnum=ck.nextInt();
String m=sc.nextLine();
if(m.equals("Y"))
{
a[i].setOutnumber(outnum);
a[i].setShipmenttime(shiptime);
}
else if(m.equals("N"))
{
caidan();
}
break;
}
else
{
System.out.println("没有该商品!");
caidan1();
}
}
}
else
{
System.out.println("输入的商品编码有误!");
caidan();
}
}
public static void pandain()
{
for(int i=0;i<5;i++)
{
System.out.printf("商品编号:"+a[i].getItemno()+"商品名称:"+a[i].getItemname()+"库存数量:"+a[i].getKucun());
System.out.printf("\n");
}
}
public void show()
{
for(int i=0;i<6;i++)
{
System.out.println(a[i].getIntemnumber());
}
}
三、
主函数控制各种操作实现:
public class Main {
public static void main(String[] args) {
boolean m=true;
WarehouseManagement.fuzhi();
WarehouseManagement a = new WarehouseManagement();
while(m)
{
a.caidan();
Scanner sc=new Scanner(System.in);
int xu=sc.nextInt();
switch(xu)
{
case 1 :
a.ruku();
break;
case 2 :
a.xiugai();
break;
case 3:
a.chuku();
break;
case 4 :
a.pandain();
}
}
}
}
标签:开学,String,System,println,测试,整理,sc,public,out From: https://www.cnblogs.com/pinganxile/p/17707059.html