WarehouseInformation数据类
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 void setItemname(String itemname) {
this.itemname = itemname;
}
public void setItemno(String itemno) {
this.itemno = itemno;
}
public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}
public String getItemname() {
return itemname;
}
public String getItemno() {
return itemno;
}
public String getShipmenttime() {
return shipmenttime;
}
public String getSuppliername() {
return suppliername;
}
public String getWarehousenumber() {
return warehousenumber;
}
public String getWarehouseplace() {
return warehouseplace;
}
public String getWarehousingtime() {
return warehousingtime;
}
public int getItemnumber() {
return itemnumber;
}
public int getOutnumber() {
return outnumber;
}
}
执行类WarehouseManagement
import com.sun.security.jgss.GSSUtil;标签:product,String,测试题,System,修改,println,public,out From: https://www.cnblogs.com/syldbk/p/17709963.html
import org.w3c.dom.ls.LSInput;
import javax.lang.model.util.ElementScanner6;
import java.util.ArrayList;
import java.util.Scanner;
public class WarehouseManagement {
ArrayList al = new ArrayList();
int a=al.size();
public static void main(String[] args) { //主函数
mainFrame();
}
public static void mainFrame(){ //主界面方法
while (true) { //主界面
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t1、商品入库管理");
System.out.println("\t\t\t\t\t2、商品信息修改");
System.out.println("\t\t\t\t\t3、商品出库管理");
System.out.println("\t\t\t\t\t4、仓库盘点管理");
System.out.println("**********************************************************");
int choice;
Scanner sc = new Scanner(System.in);
choice = sc.nextInt();//获取输入
switch (choice) { //判断选择功能界面
case 1:
goodsWarehousing();
break;
case 2:
modifyWarehousing();
break;
case 3:
outboundWarehouse();
break;
case 4:
countGoods();
break;
default:
System.out.println("该选项不存在");
break;
}
}
}
public static void goodsWarehousing(){ //商品入库方法
String itemNo;
String itemName;
String supplierName;
String warehousingTime;
String warehouseNumber;
String warehousePlace;
int itemNumber;
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t商品编号:");
itemNo = sc.next();
System.out.println("\t\t\t\t\t商品名称:");
itemName = sc.next();
System.out.println("\t\t\t\t\t供货商信息:");
supplierName = sc.next();
System.out.println("\t\t\t\t\t入库时间:");
warehousingTime = sc.next();
System.out.println("\t\t\t\t\t存放仓库号:");
warehouseNumber = sc.next();
System.out.println("\t\t\t\t\t存放位置信息:");
warehousePlace = sc.next();
System.out.println("\t\t\t\t\t入库商品数量:");
itemNumber = sc.nextInt();
System.out.println("**********************************************************");
if (itemNo.length() != 8 || warehousingTime.length() != 8 || warehouseNumber.length() != 3 || warehousePlace.length() != 8||itemNumber>0) {
System.out.println("录入错误,请重新输入");
} else {
break;
}
}
WarehouseInformation product = new WarehouseInformation();
product.setItemno(itemNo);
product.setItemname(itemName);
product.setSuppliername(supplierName);
product.setWarehousingtime(warehousingTime);
product.setWarehousenumber(warehouseNumber);
product.setWarehouseplace(warehousePlace);
product.setItemnumber(itemNumber);
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t商品编号:" + product.getItemno());
System.out.println("\t\t\t\t\t商品名称:" + product.getItemname());
System.out.println("\t\t\t\t\t供货商信息:" + product.getSuppliername());
System.out.println("\t\t\t\t\t入库时间:" + product.getWarehousingtime());
System.out.println("\t\t\t\t\t存放仓库号:" + product.getWarehousenumber());
System.out.println("\t\t\t\t\t存放位置信息:" + product.getWarehouseplace());
System.out.println("\t\t\t\t\t入库商品数量:" + product.getItemnumber());
System.out.println("\t\t\t\t该商品入库操作已完成,是否提交(Y/N)");
System.out.println("**********************************************************");
String a = sc.next();
if (a.equals('Y')) {
products[productCount] = product;
productCount++;
System.out.println("商品信息已提交");
} else {
return;
}
}
public static void modifyWarehousing(){
String itemNo;
Scanner sc = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t请输入商品编号:");
itemNo = sc.next();
System.out.println("**********************************************************");
WarehouseInformation product = findProductByItemNumber(itemNo);
if (product == null) {
System.out.println("库中没有该商品");
} else {
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t商品编号:" + product.getItemno());
System.out.println("\t\t\t\t\t商品名称:" + product.getItemname());
System.out.println("\t\t\t\t\t供货商信息:" + product.getSuppliername());
System.out.println("\t\t\t\t\t入库时间:" + product.getWarehousingtime());
System.out.println("\t\t\t\t\t存放仓库号:" + product.getWarehousenumber());
System.out.println("\t\t\t\t\t存放位置信息:" + product.getWarehouseplace());
System.out.println("\t\t\t\t\t入库商品数量:" + product.getItemnumber());
System.out.println("\t\t\t\t\t请选择需要修改的信息编号(1-7):");
System.out.println("***********************************************************");
int option = sc.nextInt();
modifyDate(int option);
}
}
public static WarehouseInformation findProductByItemNumber(String itemNumber) {
for (int i = 0; i < productCount; i++) {
WarehouseInformation product = products[i];
if (product.getItemno().equals(itemNumber)) {
return product;
}
}
return null;
}
public static void modifyDate(int option){ //修改对应选项的数据
String itemNo;
Scanner sc = new Scanner(System.in);
WarehouseInformation product = findProductByItemNumber(itemNo);
switch (option) {
case 1:
System.out.println("请输入新的商品编码:");
String newItemNumber = sc.next();
product.setItemno(newItemNumber);
System.out.println("商品编码已修改");
break;
case 2:
System.out.println("请输入新的商品名称:");
String newItemName = sc.next();
product.setItemname(newItemName);
System.out.println("商品名称已修改");
break;
case 3:
System.out.println("请输入新的供货商信息:");
String newSupplierName = sc.next();
product.setSuppliername(newSupplierName);
System.out.println("供货商信息已修改");
break;
case 4:
System.out.println("请输入新的入库时间(格式为yyyyMMdd):");
String newWarehousingTime = sc.next();
product.setWarehousingtime(newWarehousingTime);
System.out.println("入库时间已修改");
break;
case 5:
System.out.println("请输入新的存放仓库号:");
String newWarehouseNumber = sc.next();
product.setWarehousenumber(newWarehouseNumber);
System.out.println("存放仓库号已修改");
break;
case 6:
System.out.println("请输入新的存放位置信息(格式为XXXXYYZZ,其中XXXX表示货架号,YY表示货架的层号,ZZ表示存放在该货架该层的商品顺序号):");
String newWarehousePlace = sc.next();
product.setWarehouseplace(newWarehousePlace);
System.out.println("存放位置信息已修改");
break;
default:
System.out.println("该选项不存在,请重新输入");
break;
}
}
public static void outboundWarehouse (){
String itemNo;
String shipmentTime;
Scanner sc = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t请输入商品编号:");
itemNo = sc.next();
WarehouseInformation product = findProductByItemNumber(itemNo);
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t\t\t\t\t1、商品编号:" + product.getItemno());
System.out.println("\t\t\t\t\t2、商品名称:" + product.getItemname());
System.out.println("\t\t\t\t\t3、供货商信息:" + product.getSuppliername());
System.out.println("\t\t\t\t\t4、入库时间:" + product.getWarehousingtime());
System.out.println("\t\t\t\t\t5、存放仓库号:" + product.getWarehousenumber());
System.out.println("\t\t\t\t\t6、存放位置信息:" + product.getWarehouseplace());
System.out.println("\t\t\t\t\t7、入库商品数量:" + product.getItemnumber());
System.out.println("\t\t\t\t\t出库时间:");
shipmentTime = sc.next();
System.out.println("\t\t\t\t\t出库数量:");
int outNumber = sc.nextInt();
System.out.println("**********************************************************");
String a = sc.next();
if (a.equals('Y')) {
productCount--;
System.out.println("商品信息已保存");
} else {
return;
}
}
public static void addWarehouse(){
}
public static void countGoods( ){
System.out.println("***********************************************************");
System.out.println("\t\t\t石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t\t\t\t\t仓库管理系统2022版");
System.out.println("***********************************************************");
WarehouseInformation product = new WarehouseInformation();
for (int i = 0; i < productCount; i++) {
System.out.println(i + "、商品编号:" + products[i].getItemno() + "、商品名称:" + products[i].getItemname() + "、库存数量:"+(products[i].getItemnumber()-products[i].getOutnumber()));
}
System.out.println("**********************************************************");
}
}