首页 > 其他分享 >9.17

9.17

时间:2023-09-17 17:22:06浏览次数:28  
标签:scanner String 9.17 System warehouse println out

package test;

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 String getItemname() {
return itemname;
}

public String getSuppliername() {
return suppliername;
}

public String getWarehousingtime() {
return warehousingtime;
}

public String getShipmenttime() {
return shipmenttime;
}

public String getWarehousenumber() {
return warehousenumber;
}

public String getWarehouseplace() {
return warehouseplace;
}

public int getItemnumber() {
return itemnumber;
}

public int getOutnumber() {
return outnumber;
}

public void setItemno(String itemno) {
this.itemno = itemno;
}

public void setItemname(String itemname) {
this.itemname = itemname;
}

public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}

public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}

public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}

public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}

public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}

public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}

public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}

public void assign(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;
}
}
package test;

import java.util.Scanner;

public class WarehouseManagement {
public static void main(String[] args) {
WarehouseInformation[] warehouses = new WarehouseInformation[5];
Scanner scanner = new Scanner(System.in);

WarehouseInformation warehouse = new WarehouseInformation();
WarehouseInformation warehouse1 = new WarehouseInformation();
WarehouseInformation warehouse2 = new WarehouseInformation();
WarehouseInformation warehouse3 = new WarehouseInformation();
WarehouseInformation warehouse4 = new WarehouseInformation();
warehouse.setItemno("10000000");
warehouse1.setItemno("10000000");
warehouse2.setItemno("10000000");
warehouse3.setItemno("10000000");
warehouse4.setItemno("10000000");
warehouses[0]=warehouse;
warehouses[1]=warehouse;
warehouses[2]=warehouse;
warehouses[3]=warehouse;
warehouses[4]=warehouse;




//主菜单
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("***********************************************************");

while(true){
System.out.print("请输入数字选择功能:");
int option = scanner.nextInt();
if (option == 1) {
submit(warehouses, scanner);//调用入库函数
}
else if (option == 2) {
change(warehouses, scanner);//调用修改函数
}
else if (option == 3) {
ship(warehouses, scanner);//调用出库函数
}
else if (option == 4) {
review(warehouses,scanner);//调用盘点函数
}
else {
System.out.println("该选项不存在");
break;
}
}
scanner.close();
}

public static WarehouseInformation findwarehouse(WarehouseInformation[] warehouses, String itemno) {
for (int i = 0; i < warehouses.length; i++) {
if (warehouses[i] != null && warehouses[i].getItemno().equals(itemno)) {
return warehouses[i];
}
}
return null;
}
public static void submit(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");

System.out.println(" 商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (itemno.length()!=8) {
System.out.println("商品编号为8位数字,请重新输入。");
return;
}

System.out.println(" 商品名称:");
String itemname=scanner.next();

System.out.println(" 供货商信息:");
String suppliername=scanner.next();

System.out.println(" 入库时间:");
String warehousingtime=scanner.next();
if (warehousingtime.length()!=8) {
System.out.println("入库时间为8位数字,请重新输入。");
return;
}

System.out.println(" 存放仓库号:");
String warehousenumber=scanner.next();
if (warehousenumber.length()!=3) {
System.out.println("存放仓库号为3位数字,请重新输入。");
return;
}

System.out.println(" 存放位置信息:");
String warehouseplace=scanner.next();
if (warehouseplace.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}

System.out.println(" 入库商品数量:");
int itemnumber=scanner.nextInt();

System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 商品编号:"+warehouse.getItemno());
System.out.println(" 商品名称:"+warehouse.getItemname());
System.out.println(" 供货商信息:"+warehouse.getSuppliername());
System.out.println(" 入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 入库商品数量:"+warehouse.getItemnumber());

System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setItemno(itemno);
warehouse.setItemname(itemname);
warehouse.setSuppliername(suppliername);
warehouse.setWarehousingtime(warehousingtime);
warehouse.setWarehousenumber(warehousenumber);
warehouse.setWarehouseplace(warehouseplace);
warehouse.setItemnumber(itemnumber);
System.out.println("提交成功。");

} else {
System.out.println("取消提交。");
}
}

public static void change(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (warehouse == null) {
System.out.println("该商品不存在。");
return;
}
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+warehouse.getItemno());
System.out.println(" 2、商品名称:"+warehouse.getItemname());
System.out.println(" 3、供货商信息:"+warehouse.getSuppliername());
System.out.println(" 4、入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 5、存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 6、存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 7、入库商品数量:"+warehouse.getItemnumber());
System.out.println(" 请选择需要修改的信息编号(1-7):");
System.out.println("***********************************************************");
String itemname=warehouse.getItemname();
String suppliername=warehouse.getSuppliername();
String warehousingtime=warehouse.getWarehousingtime();
String warehousenumber=warehouse.getWarehousenumber();
String warehouseplace=warehouse.getWarehouseplace();
int itemnumber=warehouse.getItemnumber();

while(true){
int option = scanner.nextInt();

if (option == 1) {
System.out.println("请输入修改后的商品编号:");
itemno=scanner.next();
if (itemno.length()!=8) {
System.out.println("商品编号为8位数字,请重新输入。");
return;
}
}
else if (option == 2) {
System.out.println("请输入修改后的商品名称:");
itemname=scanner.next();

}
else if (option == 3) {
System.out.println("请输入修改后的供货商信息:");
suppliername=scanner.next();
}
else if (option == 4) {
System.out.println("请输入修改后的入库时间:");
warehousingtime=scanner.next();
if (warehousingtime.length()!=8) {
System.out.println("入库时间为8位数字,请重新输入。");
return;
}
}
else if (option == 5) {
System.out.println("请输入修改后的存放仓库号:");
warehousenumber=scanner.next();
if (warehousenumber.length()!=8) {
System.out.println("存放仓库号为3位数字,请重新输入。");
return;
}
}
else if (option == 6) {
System.out.println("请输入修改后的存放位置信息:");
warehouseplace=scanner.next();
if (warehouseplace.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}
}
else if (option == 7) {
System.out.println("请输入修改后的商品数量:");
itemnumber=scanner.nextInt();
}
else {
System.out.println("该选项不存在");
break;
}
System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setItemno(itemno);
warehouse.setItemname(itemname);
warehouse.setSuppliername(suppliername);
warehouse.setWarehousingtime(warehousingtime);
warehouse.setWarehousenumber(warehousenumber);
warehouse.setWarehouseplace(warehouseplace);
warehouse.setItemnumber(itemnumber);
System.out.println("提交成功。");
} else {
System.out.println("取消提交。");
}
}

}

public static void ship(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
String itemno=scanner.next();
WarehouseInformation warehouse = findwarehouse(warehouses, itemno);
if (warehouse == null) {
System.out.println("该商品不存在。");
return;
}
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 1、商品编号:"+warehouse.getItemno());
System.out.println(" 2、商品名称:"+warehouse.getItemname());
System.out.println(" 3、供货商信息:"+warehouse.getSuppliername());
System.out.println(" 4、入库时间:"+warehouse.getWarehousingtime());
System.out.println(" 5、存放仓库号:"+warehouse.getWarehousenumber());
System.out.println(" 6、存放仓库位置:"+warehouse.getWarehouseplace());
System.out.println(" 7、入库商品数量:"+warehouse.getItemnumber());
System.out.println(" 出库时间:");
String shipmenttime=scanner.next();
if (shipmenttime.length()!=8) {
System.out.println("存放位置为8位数字,请重新输入。");
return;
}
System.out.println(" 出库数量:");
int outnumber=scanner.nextInt();

System.out.println("***********************************************************");
System.out.print("该学生成绩已录入完毕,是否提交(Y/N):");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
warehouse.setShipmenttime(shipmenttime);
warehouse.setOutnumber(outnumber);
System.out.println("提交成功。");
} else {
System.out.println("取消提交。");
}
}

public static void review(WarehouseInformation[] warehouses,Scanner scanner){
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
for(int i=0;i<5;i++){
System.out.println("1、商品编号:"+warehouses[i].getItemno()+"2、商品名称:"+warehouses[i].getItemnumber()+"3、库存数量:"+(warehouses[i].getItemnumber()-warehouses[i].getOutnumber()));

}

}
}

标签:scanner,String,9.17,System,warehouse,println,out
From: https://www.cnblogs.com/0608lin/p/17709240.html

相关文章

  • 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的芯片要用多少片......
  • 19.17RU安装问题汇总
    问题概述19.17RU安装问题汇总一、lib库被其他用户使用二、CRS-1159:Theclustercannotbesettorollingpatchmode三、NoreadorwritepermissiontoORACLE_HOME/.patch_storage四、Datapatch:couldn'topenencmapgbk.enc五、CRS-6706:OracleClusterwareReleasepatch......
  • 9.17 泛型方法
    实际开发中非常常见没有定义泛型类,可以直接定义使用泛型方法;泛型方法不一定就出现在泛型类之中.publicclassHelloWorld{publicstaticvoidmain(Stringargs[]){Integernum[]=fun(1,2,3);//传入了整数,for(inttmp:num){System......
  • 2022.9.17:ICPC网络赛第一场
    突然意识到正式赛这个版块没有更新过什么,就打算写一个赛后总结开场跟榜开\(C\),跟队友讨论了好一会儿,\(20\)分钟才意识到和叶子结点有关,qgn上机,没看代码,觉得啥问题,结果......
  • 2022 ICPC 网络预选赛(9.17)
    L给出一个s和t求s一个最长子串使得s中不存在t中长度大于2的子串。直接的想法是状压dp不过复杂度很高。仔细考虑当前形成子串中若包含t的一个字符所形成的的限制是该字......
  • 9.17
    dos命令打开命令提示符在任意文件夹下面,或者桌面按住shift+右击,选择打开powershell窗口在文件夹窗口中,选择路径栏位,在前面加上cmd和空格常用的dos命令切换盘符......
  • 2022.9.17 Java第二次课总结
    以下是本节课后的问题首先是关于静态变量在类中,使用static修饰符修饰的属性(成员变量)称为静态变量,也可以称为类变量,常量称为静态常量,方法称为静态方法或类方法,它们统称......