首页 > 其他分享 >9.17

9.17

时间:2023-09-17 21:46:12浏览次数:33  
标签:product String 9.17 System println out scanner

import java.util.Scanner;

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 inNumber;
private int outNumber;

public WarehouseInformation() {

itemNumber = "";

itemName = "";

supplierName = "";

warehousingTime = "";

shipmentTime = "";

warehouseNumber = "";

warehousePlace = "";

inNumber = 0;
outNumber = 0;
}


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 getInNumber() {
return inNumber;
}

public void setInNumber(int inNumber) {
this.inNumber = inNumber;
}

public int getOutNumber() {
return outNumber;
}

public void setOutNumber(int outNumber) {
this.outNumber = outNumber;
}
}

class WarehouseManagement {
private static final int MAX_PRODUCTS = 5;
private static WarehouseInformation[] warehouseProducts = new WarehouseInformation[MAX_PRODUCTS];
private static int productCount = 0;

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
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("请输入数字(1-4)执行相应功能,输入其他数字退出系统:");
int choice = scanner.nextInt();
scanner.nextLine();

switch (choice) {
case 1:
manageWarehouseIn(scanner);
break;
case 2:
modifyProductInfo(scanner);
break;
case 3:
manageWarehouseOut(scanner);
break;
case 4:
doInventory();
break;
default:
System.out.println("该选项不存在,请重新输入!");
break;
}
}
}

private static void manageWarehouseIn(Scanner scanner) {
if (productCount >= MAX_PRODUCTS) {
System.out.println("仓库已满,无法继续入库!");
return;
}

WarehouseInformation product = new WarehouseInformation();
System.out.println("请输入商品编码:");

String itemNumber = scanner.nextLine();
product.setItemNumber(itemNumber);


System.out.println("请输入商品名称:");
String itemName = scanner.nextLine();
product.setItemName(itemName);

System.out.println("请输入供货商信息:");

String supplierName = scanner.nextLine();
product.setSupplierName(supplierName);

System.out.println("请输入入库时间(格式:yyyyMMdd):");

String warehousingTime = scanner.nextLine();
product.setWarehousingTime(warehousingTime);

System.out.println("请输入存放仓库号:");

String warehouseNumber = scanner.nextLine();
product.setWarehouseNumber(warehouseNumber);

System.out.println("请输入存放位置信息(格式:XXXXYYZZ):");

String warehousePlace = scanner.nextLine();
product.setWarehousePlace(warehousePlace);

System.out.println("请输入入库商品数量:");

int inNumber = scanner.nextInt();
product.setInNumber(inNumber);

scanner.nextLine();


System.out.println("商品信息如下:");
displayProductInfo(product);

System.out.println("该商品入库操作已完成,是否提交(Y/N):");
String submitChoice = scanner.nextLine();

if (submitChoice.equalsIgnoreCase("Y")) {
warehouseProducts[productCount++] = product;
System.out.println("商品信息已提交!");
} else {
System.out.println("商品信息未提交!");
}
}

private static void displayProductInfo(WarehouseInformation product) {
System.out.println("***********************************************************");
System.out.println("石家庄铁道大学前进22软件开发有限公司");
System.out.println("仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("商品编号:" + product.getItemNumber());
System.out.println("商品名称:" + product.getItemName());
System.out.println("供货商信息:" + product.getSupplierName());
System.out.println("入库时间:" + product.getWarehousingTime());
System.out.println("存放仓库号:" + product.getWarehouseNumber());
System.out.println("存放位置信息:" + product.getWarehousePlace());
System.out.println("入库商品数量:" + product.getInNumber());
}

private static void modifyProductInfo(Scanner scanner) {
System.out.println("请输入商品编号:");
String itemNumber = scanner.nextLine();

int index = findProductIndex(itemNumber);
if (index == -1) {
System.out.println("库中没有该商品!");
return;
}

WarehouseInformation product = warehouseProducts[index];
displayProductInfo(product);

System.out.println("请选择需要修改的信息编号(1-7):");
int modifyChoice = scanner.nextInt();
scanner.nextLine(); // 消耗换行符

switch (modifyChoice) {
case 1:
System.out.println("请输入修改后的商品编号:");
String newItemNumber = scanner.nextLine();
product.setItemNumber(newItemNumber);
break;
case 2:
System.out.println("请输入修改后的商品名称:");
String newItemName = scanner.nextLine();
product.setItemName(newItemName);
break;
case 3:
System.out.println("请输入修改后的供货商信息:");
String newSupplierName = scanner.nextLine();
product.setSupplierName(newSupplierName);
break;
case 4:
System.out.println("请输入修改后的入库时间(格式:yyyyMMdd):");
String newWarehousingTime = scanner.nextLine();
product.setWarehousingTime(newWarehousingTime);
break;
case 5:
System.out.println("请输入修改后的存放仓库号:");
String newWarehouseNumber = scanner.nextLine();
product.setWarehouseNumber(newWarehouseNumber);
break;
case 6:
System.out.println("请输入修改后的存放位置信息(格式:XXXXYYZZ):");
String newWarehousePlace = scanner.nextLine();
product.setWarehousePlace(newWarehousePlace);
break;
case 7:
System.out.println("请输入修改后的商品数量:");
int newInNumber = scanner.nextInt();
product.setInNumber(newInNumber);
break;
default:
System.out.println("该选项不存在,请重新输入!");
break;
}

System.out.println("是否保存修改信息(Y/N):");
String saveChoice = scanner.nextLine();

if (saveChoice.equalsIgnoreCase("Y")) {
System.out.println("修改信息已保存!");
} else {
System.out.println("修改信息未保存!");
}
}

private static int findProductIndex(String itemNumber) {
for (int i = 0; i < productCount; i++) {
if (warehouseProducts[i].getItemNumber().equals(itemNumber)) {
return i;
}
}
return -1;
}

private static void manageWarehouseOut(Scanner scanner) {
System.out.println("请输入商品编号:");
String itemNumber = scanner.nextLine();

int index = findProductIndex(itemNumber);
if (index == -1) {
System.out.println("库中没有该商品!");
return;
}

WarehouseInformation product = warehouseProducts[index];
displayProductInfo(product);

System.out.println("请输入出库时间(格式:yyyyMMdd):");
String shipmentTime = scanner.nextLine();
product.setShipmentTime(shipmentTime);

System.out.println("请输入出库数量:");
int outNumber = scanner.nextInt();
product.setOutNumber(outNumber);

scanner.nextLine();

if (outNumber <= product.getInNumber()) {
System.out.println("出库操作已完成!");
} else {
System.out.println("出库数量大于库存数量,出库操作失败!");
product.setShipmentTime("");
product.setOutNumber(0);
}
}

private static void doInventory() {
System.out.println("仓库盘点功能暂未实现!");
}
}

标签:product,String,9.17,System,println,out,scanner
From: https://www.cnblogs.com/lml66/p/17709878.html

相关文章

  • 畅购商城学习日志9.17
    org.springframework.beans.factory.BeanDefinitionStoreException:Failedtoparseconfigurationclass[com.changgou.GoodsApplication];nestedexceptionisorg.springframework.context.annotation.ConflictingBeanDefinitionException:Annotation-specifiedbeann......
  • 9.17课堂测试更改代码
    importjava.util.ArrayList;importjava.util.Scanner;publicclassmainFrame{publicstaticvoidmain(String[]args){ArrayList<WarehouseInformation>array=newArrayList<WarehouseInformation>();while(true){Syste......
  • 测试重写9.17
    packageqiyexinxi;importjava.util.Scanner;publicclassqiyexinxi{ //定义WarehouseInformation类publicstaticclassWarehouseInformation{privateStringitemno;//商品编号privateStringitemname;//商品名称privateStringsuppliername;//供货商名称pri......
  • 登录界面9.17
    packagetest;importjavax.swing.*;importjava.awt.*;publicclasstest2{//创造字符串储存账号publicstaticStringuname[]=newString[100];//创造字符串储存密码publicstaticStringupass[]=newString[100];//记录当前坐标publicstaticintflag_user......
  • 9.17 四次分解
     Importjava.util.Scanner; PublicclassWarehouseManagement{StaticintnumOfItems=0;StaticWarehouseInformation[]warehouseInformations=newWarehouseInformation[5]; Publicstaticvoidmain(String[]args){       initializeData();  ......
  • 每日总结|9.17-别为打翻的牛奶哭泣,今天你能拥有更美味的果汁
    超级喜欢两首歌:越来越不懂-蔡健雅你不明白-Joysaaaa今天没干什么其实,都是一些不太费脑子的。休息了,恢复精力,下周才能元气满满啊!1、王老师的需求文档作业,做了一部分,查一些资料2、看学习视频3、人月神话,今天看了不到两章(我本来还说要每天看一点呢,结果还是比较忙的)4、c#(......
  • 开学测试修改(9.17)
    packagehomework;publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStr......
  • 9.17
    packagetest;publicclassWarehouseInformation{privateStringitemno;//编号,八位数字privateStringitemname;//名称privateStringsuppliername;//供货商privateStringwarehousingtime;//入库时间,八位数字privateStringshipmenttime;//出库时间,......
  • 9.17 小试牛刀
    实操设计小米官网网站设计顶层黑色导航(9.17)遇到的问题1.如何链接css?<linkrel="stylesheet"type="text/css"href="style.css"/>2.如何去除无序列表前面的小点?list-style:none;3.如何弄走链接的下划线?text-decoration:none;小米logo如何与其他文字并排?这个......
  • 2023.9.17日报
    今天了解了软考的相关内容,值得一提的是,软考的上午题中有很多没有学过的内容例如计算机组成原理和操作系统,另外自己的数据结构和计算机网络也有所遗忘因此需要往回捡捡,今天了解了一些cpu的知识点,还有一些编码的内容必须要记住的是,给出一个区间,例如用32kX8bit的芯片要用多少片......