WarehouseInformation类
package STD_STD;
public class WarehouseInformation {
private String itemnumber;
private String itemname;
private String suppliername;
private String warehousingtime;
private String shipmenttime;
private String warehousenumber;
private String warehouseplace;
private int itemno;
private int outnumber;
public WarehouseInformation() {
}
public WarehouseInformation(String itemnumber, String itemname, String suppliername, String warehousingtime, String warehousenumber, String warehouseplace, int itemno) {
this.itemnumber = itemnumber;
this.itemname = itemname;
this.suppliername = suppliername;
this.warehousingtime=warehousingtime;
this.warehousenumber = warehousenumber;
this.warehouseplace = warehouseplace;
this.itemno = itemno;
}
public String getItemnumber() {
return itemnumber;
}
public void setItemnumber(String itemnumber) {
this.itemnumber = itemnumber;
}
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 getItem_number() {
return itemno;
}
public void setItem_number(int itemno) {
this.itemno = itemno;
}
public int getOutnumber() {
return outnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
}
WarehouseManagemen类
package STD_STD;
import java.util.ArrayList;
import java.util.Scanner;
public class WarehouseManagement {
public static void main(String[] args) {
ArrayList<WarehouseInformation>list=new ArrayList<>();
mainFrame(list);
}
public static void mainFrame(ArrayList<WarehouseInformation> list)
{
Scanner sc=new Scanner(System.in);
while(true){
bg();
int num=sc.nextInt();
switch (num){
case 1->goodsWarehousing(list);
case 2->modifyWarehouse(list);
case 3->outboundWarehouse(list);
case 4-> {
guanli(list);
System.exit(0);
}
default -> System.out.println("该选项不存在");
}
}
}
public static void bg1(){
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
""");
}
private static void goodsWarehousing(ArrayList<WarehouseInformation>list) {
Scanner sc = new Scanner(System.in);
bg1();
WarehouseInformation w1=new WarehouseInformation();
while (true) {
System.out.print(" 商品编号:");
w1.setItemnumber(sc.next());
System.out.println();
System.out.print(" 商品名称:");
w1.setItemname(sc.next());
System.out.println();
System.out.print(" 供货商信息:");
w1.setSuppliername(sc.next());
System.out.println();
System.out.print(" 入库时间:");
w1.setWarehousingtime(sc.next());
System.out.println();
System.out.print(" 存放仓库号:");
w1.setWarehousenumber(sc.next());
System.out.println();
System.out.print(" 存放位置信息:");
w1.setWarehouseplace(sc.next());
System.out.println();
System.out.print(" 入库商品数量:");
w1.setItem_number(sc.nextInt());
System.out.println();
System.out.println("***********************************************************");
if(w1.getItemnumber().length()==8&&w1.getWarehousenumber().length()==3&&w1.getWarehouseplace().length()==8){
break;
}
else {
System.out.println("录入错误");
}
}
System.out.println(" 商品编号:"+w1.getItemnumber());
System.out.println(" 商品名称:"+w1.getItemname());
System.out.println(" 供货商信息:"+w1.getSuppliername());
System.out.println(" 入库时间:"+w1.getWarehousingtime());
System.out.println(" 存放仓库号"+w1.getWarehousenumber());
System.out.println(" 存放位置信息:"+w1.getWarehouseplace());
System.out.println(" 入库商品数量:"+w1.getItem_number());
System.out.println(" 该商品入库操作已完成,是否提交(Y/N)\n" +
"**********************************************************\n");
char a=sc.next().charAt(0);
if(a=='Y'||a=='y'){
list.add(w1);
}
else {
goodsWarehousing(list);
}
}
private static void modifyWarehouse(ArrayList<WarehouseInformation> list) {
Scanner sc=new Scanner(System.in);
while (true) {
bg1();
String num;
System.out.print("请输入商品编号(8位):");
num = sc.next();
System.out.println();
System.out.println("**********************************************************");
int i=getindex(list,num);
if(getindex(list,num)!=-1){
bg1();
System.out.println(" 1.商品编号:"+list.get(i).getItemnumber());
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).getItem_number());
System.out.print(" 请选择需要修改的信息编号(1-7):");
int temp=sc.nextInt();
System.out.println();
System.out.print(" 请输入修改后的商品名称");
switch (temp){
case 1->list.get(i).setItemnumber(sc.next());
case 2->list.get(i).setItemname(sc.next());
case 3->list.get(i).setSuppliername(sc.next());
case 4->list.get(i).setWarehousingtime(sc.next());
case 5->list.get(i).setWarehousenumber(sc.next());
case 6->list.get(i).setWarehouseplace(sc.next());
case 7->list.get(i).setItem_number(sc.nextInt());
default -> {
System.out.println("该选项不存在");
break;
}
}
System.out.println("**********************************************************");
System.out.println(" 该商品修改操作已完成,是否提交(Y/N)");
char a=sc.next().charAt(0);
if(a=='Y'||a=='y'){
break;
}
else {
break;
}
}
else {
System.out.println("没有该商品");
}
}
}
public static int getindex(ArrayList<WarehouseInformation>list,String id) {
for (int i = 0; i < list.size(); i++) {
if(list.get(i).getItemnumber().equals(id)){
return i;
}
}
return -1;}
private static void outboundWarehouse(ArrayList<WarehouseInformation> list) {
Scanner sc=new Scanner(System.in);
while (true) {
bg1();
String num;
System.out.print("请输入商品编号(8位):");
num = sc.next();
System.out.println();
System.out.println("**********************************************************");
int i=getindex(list,num);
if(i!=-1){
bg1();
System.out.println(" 1.商品编号:"+list.get(i).getItemnumber());
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).getItem_number());
System.out.print(" 出库时间:");
list.get(i).setShipmenttime(sc.next());
System.out.println();
System.out.print(" 出库数量:");
while (true) {
int t_num = sc.nextInt();
if (t_num < list.get(i).getItem_number()) {
list.get(i).setOutnumber(t_num);
System.out.println();
System.out.println("**********************************************************");
break;
} else {
System.out.println();
System.out.println("错误!请重新输入");
}
}
System.out.println("该商品出库操作已完成,Y(保存结果,返回系统主界面)/N(返回当前界面)");
char c=sc.next().charAt(0);
if(c=='Y'||c=='y'){
break;
}
}
else {
System.out.println("商品不存在");
}
}
}
private static void guanli(ArrayList<WarehouseInformation> list) {
bg1();
for (int i = 0; i < list.size(); i++) {
int countWarehouse=list.get(i).getItem_number()-list.get(i).getOutnumber();
System.out.println((i+1)+"、 "+"商品编号:"+list.get(i).getItemnumber()+"、商品名称:"+list.get(i).getItemname()+"、库存数量:"+countWarehouse);
}
System.out.println("**********************************************************");
}
private static void bg() {
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
1、商品入库管理
2、商品信息修改
3、商品出库管理
4、仓库盘点管理
**********************************************************
""");
}
}
标签:开学,String,管理系统,get,list,System,println,重写,out
From: https://www.cnblogs.com/drip3775/p/17704109.html