package homework;
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 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;
}
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 WarehouseInformation() {
}
}
*************************************************************************************************************************************************************************************************
标签:开学,String,9.17,list,System,break,测试,println,out From: https://www.cnblogs.com/HD-Kudu-2219/p/17709466.html
-----------------------------------------------------------------------------------分界线---------------------------------------------------------------------------------------------------------
*************************************************************************************************************************************************************************************************
package homework;
import java.util.ArrayList;
import java.util.Scanner;
public class WarehouseManagement {
public static void main(String[] args) {
ArrayList<WarehouseInformation> list = new ArrayList<>();
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t"+"1、商品入库管理");
System.out.println("\t"+"2、商品信息修改");
System.out.println("\t"+"3、商品出库管理");
System.out.println("\t"+"4、仓库盘点管理");
System.out.println("\t"+"5、退出");
System.out.println("***********************************************************");
loop:while (true) {
System.out.println("请选择:");
Scanner sc = new Scanner(System.in);
String num = sc.next();
switch(num) {
case "1":
System.out.println("已选择商品入库管理");
addw(list);
break;
case "2":
System.out.println("已选择商品信息修改");
changew(list);
break;
case "3":
System.out.println("已选择商品出库管理");
//outw(list);
break;
case "4":
System.out.println("已选择仓库盘点管理");
panDianw(list);
break;
case "5":
System.out.println("已选择退出");
break loop;
default:
System.out.println("没有这个选项");
break;
}
}
}
//商品入库管理
public static void addw(ArrayList<WarehouseInformation> list) {
loop0: while (true) {
WarehouseInformation w = new WarehouseInformation();
Scanner sc = new Scanner(System.in);
System.out.println("商品编号:");
String itemno = sc.next();
boolean flag1 = judge(list,itemno);
if(flag1){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
System.out.println("商品名称:");
String itemname = sc.next();
w.setItemname(itemname);
System.out.println("供货商信息:");
String suppliername = sc.next();
w.setSuppliername(suppliername);
System.out.println("入库时间:");
String warehousingtime = sc.next();
boolean flag2 = judge(list,warehousingtime);
if(flag2){
w.setWarehousingtime(warehousingtime);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("存放仓库号:");
String warehousenumber = sc.next();
boolean flag3 = judge(list,warehousenumber);
if(flag3){
w.setWarehousenumber(warehousenumber);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("存放位置信息:");
String warehouseplace = sc.next();
boolean flag4 = judge(list,warehouseplace);
if(flag4){
w.setWarehouseplace(warehouseplace);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("入库商品数量:");
int itemnumber = sc.nextInt();
w.setItemnumber(itemnumber);
System.out.println("保存完成");
System.out.println("***********************************************************");
System.out.println("\t" + "石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t" + " 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("商品编号:" + itemno);
System.out.println("商品名称:" + itemname);
System.out.println("供货商信息:" + suppliername);
System.out.println("入库时间:" + warehousingtime);
System.out.println("存放仓库号:" + warehousenumber);
System.out.println("存放位置信息:" + warehouseplace);
System.out.println("入库商品数量:" + itemnumber);
System.out.println("该商品入库操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break loop0;
}
else{
break loop0;
}
}
}
//商品信息修改
public static void changew(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
WarehouseInformation w=new WarehouseInformation();
Scanner sc =new Scanner(System.in);
String itemno=null;
while (true) {
System.out.print("请输入商品编号:");
itemno = sc.next();
boolean flag1 = judge(list,itemno);
if(flag1){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
boolean flag = contains(list, itemno);
if (flag) {
System.out.println("商品编号不存在,请重新输入:");
}
else {
w.setItemno(itemno);
loop1: for (int i = 0; i < list.size(); i++){
WarehouseInformation war = list.get(i);
System.out.println("***********************************************************");
System.out.println("\t" + "石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t" + " 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("商品编号:" + war.getItemno());
System.out.println("商品名称:" + war.getItemname());
System.out.println("供货商信息:" + war.getSuppliername());
System.out.println("入库时间:" + war.getWarehousingtime());
System.out.println("存放仓库号:" + war.getWarehousenumber());
System.out.println("存放位置信息:" + war.getWarehouseplace());
System.out.println("入库商品数量:" + war.getItemnumber());
loop2:while (true) {
System.out.println("请选择需要修改的信息编号(1-7):");
int num = sc.nextInt();
switch(num){
case 1:System.out.print("请输入修改后的商品编号:");
itemno = sc.next();
boolean flag11 = judge(list,itemno);
if(flag11){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
break loop2;
case 2:System.out.print("请输入修改后的商品名称:");
String itemname = sc.next();
w.setItemname(itemname);
break loop2;
case 3:System.out.print("请输入修改后的供货商信息:");
String suppliername = sc.next();
w.setSuppliername(suppliername);
break loop2;
case 4:System.out.print("请输入修改后的入库时间:");
String warehousingtime = sc.next();
boolean flag22 = judge(list,warehousingtime);
if(flag22){
w.setWarehousingtime(warehousingtime);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 5:System.out.print("请输入修改后的存放仓库号:");
String warehousenumber = sc.next();
boolean flag33 = judge(list,warehousenumber);
if(flag33){
w.setWarehousenumber(warehousenumber);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 6:System.out.print("请输入修改后的存放位置信息:");
String warehouseplace = sc.next();
boolean flag44 = judge(list,warehouseplace);
if(flag44){
w.setWarehouseplace(warehouseplace);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 7:System.out.print("请输入修改后的入库商品数量:");
int itemnumber = sc.nextInt();
w.setItemnumber(itemnumber);
break loop2;
default:
System.out.println("该选项不存在");
}
}
System.out.println("该商品修改操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break loop1;
}
else{
break loop1;
}
}
break;
}
}
}
//商品出库管理
public static void outw(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
WarehouseInformation w=new WarehouseInformation();
Scanner sc =new Scanner(System.in);
String itemno=null;
loop02:while (true) {
System.out.print("请输入商品编号:");
itemno = sc.next();
boolean flag = contains(list, itemno);
if (flag) {
System.out.println("商品编号不存在,请重新输入:");
}
else {
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
w.setItemno(itemno);
System.out.println("商品编号:" + war.getItemno());
System.out.println("商品名称:" + war.getItemname());
System.out.println("供货商信息:" + war.getSuppliername());
System.out.println("入库时间:" + war.getWarehousingtime());
System.out.println("存放仓库号:" + war.getWarehousenumber());
System.out.println("存放位置信息:" + war.getWarehouseplace());
System.out.println("入库商品数量:" + war.getItemnumber());
break;
}
int num;
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
System.out.println("请输入出库数量:");
num = sc.nextInt();
if (num <= war.getItemnumber()) {
countWarehouse(num,list);
break loop02;
}
else {
System.out.println("出库数量错误!");
}
}
}
System.out.println("该商品修改操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break ;
}
else{
break ;
}
}
}
}
//仓库盘点管理
public static void panDianw(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
for (int i = 1; i < list.size(); i++){
WarehouseInformation war = list.get(i);
int x=war.getItemnumber()-war.getOutnumber();
System.out.println(i+"、"+"商品编号:"+war.getItemno()+"、"+"商品名称:"+war.getItemname()+"、"+"库存数量:"+x);
}
System.out.println("***********************************************************");
}
public static boolean contains(ArrayList<WarehouseInformation> list ,String itemno){
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
String sid =war.getItemno();
if(sid.equals(itemno)){
return false;
}
}
return true;
}
public static boolean judge(ArrayList<WarehouseInformation> list,String str){
if(str.length() != 8 && str.length() !=3){
return false;
}else{
for (int i = 0; i < str.length(); i++) {
if(!(str.charAt(i)<='9' && str.charAt(i)>= '0')){
return false;
}
}
}
return true;
}
public static void countWarehouse(int num,ArrayList<WarehouseInformation> list){
int snum = 0;
for (int i = 0; i < 1; i++) {
WarehouseInformation war = list.get(i);
snum = war.getItemnumber() - num;
System.out.println("剩余库存数为:" + snum);
war.setItemnumber(snum);
}
}
}