//信2205-1 220223922 王凌霄
import java.util.ArrayList;
import java.util.Scanner;
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;//表示出库商品的数量。
public WarehouseInformation() {
itemno=null;
itemname=null;
suppliername=null;
warehousingtime=null;
shipmenttime=null;
warehousenumber=null;
warehouseplace=null;
itemnumber=0;
outnumber=0;
}
public int set_itemno(String ite) {
if(ite.length()!=8)
{
return -1;
}
itemno=ite;
return 1;
}
public void set_itemname(String ite) {
itemname=ite;
}
public void set_suppliername(String ite) {
suppliername=ite;
}
public int set_warehousingtime(String ite) {
if(ite.length()!=8)
{
return -1;
}
warehousingtime=ite;
return 1;
}
public int set_shipmenttime(String ite) {//出库时间必须大于入库时间
int a = Integer.parseInt(warehousingtime);
int b = Integer.parseInt(ite);
if(ite.length()!=8)
{
return -1;
}
if(a>b)
{
return -1;
}
shipmenttime=ite;
return 1;
}
public int set_warehousenumber(String ite) {
if(ite.length()!=3)
{
return -1;
}
warehousenumber=ite;
return 1;
}
public void set_itemnumber(int ite) {
itemnumber=ite;
}
public void set_warehouseplace(String ite) {
warehouseplace=ite;
}
public void set_outnumber(int ite) {
outnumber=ite;
}
//get
public String get_itemno() {
return itemno;
}
public String get_itemname() {
return itemname;
}
public String get_suppliername() {
return suppliername;
}
public String get_warehousingtime() {
return warehousingtime;
}
public String get_shipmenttime() {
return shipmenttime;
}
public String get_warehousenumber() {
return warehousenumber;
}
public String get_warehouseplace() {
return warehouseplace;
}
public int get_itemnumber() {
return itemnumber;
}
public int get_outnumber() {
return outnumber;
}
}
public class WarehouseManagement{
public static void main(String[] args) {
WarehouseManagement warehouse = new WarehouseManagement();
sc=new Scanner(System.in);
while(true)
{
showmenu();
System.out.println("请输入要选择的选项");
int select=sc.nextInt();
switch (select)
{
case 1:
inputmanage();
break;
case 2:
modify();
break;
case 3:
shipmanage();
break;
case 4:
display();
break;
default:
System.out.println("请输入1-4之间的数");
break;
}
}
}
private static Scanner sc;
public static ArrayList<WarehouseInformation> items;
public WarehouseManagement() {
items = new ArrayList<WarehouseInformation>();
}
public static void showmenu(){
System.out.println(
"***********************************************************\n"+
" 石家庄铁道大学前进22软件开发有限公司\n" +
" 仓库管理系统2022版\n" +
"***********************************************************\n" +
"\t1、商品入库管理\n" +
"\t2、商品信息修改\n" +
"\t3、商品出库管理\n" +
"\t4、仓库盘点管理\n" +
"**********************************************************\n");
}
public static void inputmanage(){
WarehouseInformation ware=new WarehouseInformation();
System.out.print("*************************石家庄铁道大学前进22软件开发有限公司*******************************\n" +
"****************************仓库管理系统2022版******************************\n" +
"商品编号:");
sc=new Scanner(System.in);
while(true)
{
String itemno_=sc.next();
if(itemno_.length()==8)
{
ware.set_itemno(itemno_);
break;
}
System.out.println("商品编号是八位数");
}
System.out.print("\n商品名称:");
String itemname_= sc.next();
ware.set_itemname(itemname_);
System.out.print("\n供货商信息:");
String suppliername_= sc.next();
ware.set_suppliername(suppliername_);
System.out.print("\n入库时间:");
while(true)
{
String warehousingtime_= sc.next();
if(warehousingtime_.length()==8)
{
ware.set_warehousingtime(warehousingtime_);
break;
}
System.out.println("存放日期必须是8位数例如20220625");
}
System.out.print("\n存放仓库号:");
while(true)
{
String warehousenumber_= sc.next();
if(warehousenumber_.length()==3)
{
ware.set_warehousenumber(warehousenumber_);
break;
}
System.out.println("仓库号必须是3位数");
}
System.out.print("\n存放位置信息:");
String warehouseplace_= sc.next();
ware.set_warehouseplace(warehouseplace_);
System.out.print("\n入库商品数量:");
int itemnumber_= sc.nextInt();
ware.set_itemnumber(itemnumber_);
System.out.println("该商品入库操作已完成,是否提交(Y/N)\n" +
"**********************************************************\n");
String a=sc.next();
if(a.equals("y")||a.equals("Y")){
items.add(ware);
}
}
private static void modify(){
System.out.print("\t石家庄铁道大学前进22软件开发有限公司\n" +
"\t仓库管理系统2022版***********************************************************\n" +
"\t请输入商品编号:XXXXXXXX\n" +
"**********************************************************\n" +
"请输入八位的商品编号:");
sc=new Scanner(System.in);
String a=sc.next();
WarehouseInformation ware=new WarehouseInformation();
for (Object item : items) {
item=(WarehouseInformation)item;
if(a.equals(((WarehouseInformation) item).get_itemno())){
System.out.println("\t石家庄铁道大学前进22软件开发有限公司\n" +
"************************仓库管理系统2022版******************************\n" +
"1、商品编号:" +((WarehouseInformation) item).get_itemno()+
"\n2、商品名称:" +((WarehouseInformation) item).get_itemname()+
"\n3、供货商信息:" +((WarehouseInformation) item).get_suppliername()+
"\n4、入库时间:" +((WarehouseInformation) item).get_warehousingtime()+
"\n5、存放仓库号:" +((WarehouseInformation) item).get_warehousenumber()+
"\n6、存放位置信息:" +((WarehouseInformation) item).get_warehouseplace()+
"\n7、入库商品数量:" +((WarehouseInformation) item).get_itemnumber()+
"\n请选择需要修改的信息编号(1-7):\n" +
"**********************************************************\n");
ware=(WarehouseInformation) item;
}
else {
System.out.println("未查询到该商品");
return;
}
}
System.out.println("输入需要修改的项目:");
int i = sc.nextInt();
switch (i){
case 1:
System.out.println("商品编号");
String itemno_=sc.next();
ware.set_itemno(itemno_);
break;
case 2:
System.out.print("商品名称:");
String itemname_= sc.next();
ware.set_itemname(itemname_);
break;
case 3:
System.out.print("供货商信息:");
String suppliername_= sc.next();
ware.set_suppliername(suppliername_);
break;
case 4:
System.out.print("入库时间:");
String warehousingtime_= sc.next();
ware.set_warehousingtime(warehousingtime_);
break;
case 5:
System.out.print("存放仓库号:");
String warehousenumber_= sc.next();
ware.set_warehousenumber(warehousenumber_);
break;
case 6:
System.out.print("存放位置信息:");
String warehouseplace_= sc.next();
ware.set_warehouseplace(warehouseplace_);
break;
case 7:
System.out.print("入库商品数量:");
int itemnumber_= sc.nextInt();
ware.set_itemnumber(itemnumber_);
break;
default:
System.out.println("输入错误,请在1-7中选择");
}
}
private static void shipmanage(){
System.out.println("***********************************************************石家庄铁道大学前进22软件开发有限公司\n" +
"仓库管理系统2022版***********************************************************\n" +
"请输入商品编号:XXXXXXXX\n" +
"**********************************************************\n" +
"请输入需要出库的商品编号:");
sc=new Scanner(System.in);
String a=sc.next();
WarehouseInformation ware=new WarehouseInformation();
for (Object item : items) {
item=(WarehouseInformation)item;
if(a.equals(((WarehouseInformation) item).get_itemno())){
System.out.println("***********************************************************石家庄铁道大学前进22软件开发有限公司\n" +
"仓库管理系统2022版***********************************************************\n" +
"1、商品编号:" +((WarehouseInformation) item).get_itemno()+
"\n2、商品名称:" +((WarehouseInformation) item).get_itemname()+
"\n3、供货商信息:" +((WarehouseInformation) item).get_suppliername()+
"\n4、入库时间:" +((WarehouseInformation) item).get_warehousingtime()+
"\n5、存放仓库号:" +((WarehouseInformation) item).get_warehousenumber()+
"\n6、存放位置信息:" +((WarehouseInformation) item).get_warehouseplace()+
"\n7、入库商品数量:" +((WarehouseInformation) item).get_itemnumber()+
"\n请选择需要修改的信息编号(1-7):\n" +
"**********************************************************\n" +
"8出库时间:XXXXXXXXX\n" +
"9出库数量:xxx\n");
System.out.println("请输入出库时间:");
String time=sc.next();
int num=0;
while(true)
{
System.out.println("请输入出库数量");
num=sc.nextInt();
if(num<=((WarehouseInformation) item).get_itemnumber()){
break;
}
System.out.println("出库数量不能大于商品数量");
}
System.out.println("是否保存?y or n");
String s=sc.next();
if(s.equals("y")||s.equals("Y")){
((WarehouseInformation) item) .set_shipmenttime(time);
((WarehouseInformation) item).set_outnumber(num);
}
}
else {
System.out.println("未查询到该商品");
return;
}
}
}
static void display(){
System.out.println("***********************************************************");
int i=1;
for (Object item : items) {
WarehouseInformation ware=(WarehouseInformation)item;
int num=ware.get_itemnumber()-ware.get_outnumber();
System.out.println(i+"、\t商品编号:"+ ware.get_itemno()+"、商品名称:"+ware.get_itemname()+"、库存数量:"+num);
i++;
}
}
}
标签:String,get,WarehouseInformation,System,sc,915,打卡,重写,out
From: https://www.cnblogs.com/wlxdaydayup/p/17706010.html