首页 > 其他分享 >开学测试

开学测试

时间:2023-09-17 20:26:58浏览次数:36  
标签:scanner 开学 String System 测试 println public out

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 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;
}

// getter和setter方法
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;
}
}
import java.util.Scanner;

public class WarehouseManagement {
private final WarehouseInformation[] warehouseInfos;
private int numOfItems;

public WarehouseManagement() {
warehouseInfos = new WarehouseInformation[5]; // 存储五个商品入库信息
numOfItems = 0;
}

// 主界面
public void mainMenu() {
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("**********************************************************");

Scanner scanner = new Scanner(System.in);
System.out.print("请输入您的选择(输入数字1-4):");
int choice = scanner.nextInt();
switch (choice) {
case 1:
itemWarehousing();
break;
case 2:
itemin();
// 商品信息修改功能
break;
case 3:
itemout();
// 商品出库管理功能
break;
case 4:
itemnem();
break;
default:
System.out.println("该选项不存在,请重新选择。");
mainMenu();
}
}
public void itemin() {
Scanner scanner = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println("石家庄铁道大学前进22软件开发有限公司");
System.out.println("仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("请输入商品编号:");
String itemno = scanner.nextLine();

// 检查商品信息是否存在
boolean itemExist = false;
int index = -1;
for (int i = 0; i < numOfItems; i++) {
if (warehouseInfos[i].getItemno().equals(itemno)) {
itemExist = true;
index = i;
break;
}
}

if (!itemExist) {
System.out.println("库中没有该商品,请重新输入商品编号。");
itemin(); // 返回商品信息修改界面
return;
}

WarehouseInformation warehouseInfo = warehouseInfos[index];

Scanner confirmScanner = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println("石家庄铁道大学前进22软件开发有限公司");
System.out.println("仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("1、商品编号:" + warehouseInfo.getItemno());
System.out.println("2、商品名称:" + warehouseInfo.getItemname());
System.out.println("3、供货商信息:" + warehouseInfo.getSuppliername());
System.out.println("4、入库时间:" + warehouseInfo.getWarehousingtime());
System.out.println("5、存放仓库号:" + warehouseInfo.getWarehousenumber());
System.out.println("6、存放位置信息:" + warehouseInfo.getWarehouseplace());
System.out.println("7、商品数量:" + warehouseInfo.getItemnumber());
System.out.println("请选择需要修改的信息编号(1-7):");
int choice = confirmScanner.nextInt();

switch (choice) {
case 1:
// 商品编号无法修改,不做任何操作
break;
case 2:
System.out.println("请输入修改后的商品名称:");
String modifiedItemName = scanner.nextLine();
warehouseInfo.setItemname(modifiedItemName);
break;
case 3:
System.out.println("请输入修改后的供货商信息:");
String modifiedSupplierName = scanner.nextLine();
warehouseInfo.setSuppliername(modifiedSupplierName);
break;
case 4:
System.out.println("请输入修改后的入库时间:");
String modifiedWarehousingTime = scanner.nextLine();
warehouseInfo.setWarehousingtime(modifiedWarehousingTime);
break;
case 5:
System.out.println("请输入修改后的存放仓库号:");
String modifiedWarehousenumber = scanner.nextLine();
warehouseInfo.setWarehousenumber(modifiedWarehousenumber);
break;
case 6:
System.out.println("请输入修改后的存放位置信息:");
String modifiedWarehouseplace = scanner.nextLine();
warehouseInfo.setWarehouseplace(modifiedWarehouseplace);
break;
case 7:
System.out.println("请输入修改后的商品数量:");
int modifiedItemNumber = scanner.nextInt();
warehouseInfo.setItemnumber(modifiedItemNumber);
break;
default:
System.out.println("该选项不存在,请重新选择。");
mainMenu();
return;
}

Scanner saveScanner = new Scanner(System.in);
System.out.println("该商品信息已修改,是否保存提交(Y/N):");
String confirm = saveScanner.nextLine();
if (confirm.equalsIgnoreCase("Y")) {
System.out.println("商品信息已保存并返回主界面。");
mainMenu();
} else if (confirm.equalsIgnoreCase("N")) {
itemin(); // 返回商品信息修改界面
} else {
System.out.println("输入错误,请重新选择。");
mainMenu();
}
}

private void itemnem() {

}

private void itemout() {
Scanner scanner = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println(" 请输入商品编号:");
String itemno = scanner.nextLine();
System.out.println("**********************************************************");

}

// 商品入库管理
public void itemWarehousing() {
Scanner scanner = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("商品编号:");
String itemno = scanner.nextLine();
System.out.println("商品名称:");
String itemname = scanner.nextLine();
System.out.println("供货商信息:");
String suppliername = scanner.nextLine();
System.out.println("入库时间:");
String warehousingtime = scanner.nextLine();
System.out.println("存放仓库号:");
String warehousenumber = scanner.nextLine();
System.out.println("存放位置信息:");
String warehouseplace = scanner.nextLine();
System.out.println("入库商品数量:");
int itemnumber = scanner.nextInt();

// 检查录入格式是否正确
if (!checkInputFormat(itemno, warehousingtime, warehousenumber, warehouseplace)) {
System.out.println("录入错误,请重新录入正确的信息。");
itemWarehousing();
return;
}

Scanner confirmScanner = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学前进22软件开发有限公司");
System.out.println(" 仓库管理系统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("该商品入库操作已完成,是否提交(Y/N):");
String confirm = confirmScanner.nextLine();
if (confirm.equalsIgnoreCase("Y")) {
WarehouseInformation warehouseInfo = new WarehouseInformation(itemno, itemname, suppliername, warehousingtime, "", warehousenumber, warehouseplace, itemnumber, 0);
warehouseInfos[numOfItems] = warehouseInfo;
numOfItems++;

System.out.println("商品信息已存储到相应的数组中,并返回主界面。");
mainMenu();
} else if (confirm.equalsIgnoreCase("N")) {
itemWarehousing(); // 返回商品入库界面
} else {
System.out.println("输入错误,请重新选择。");
mainMenu();
}
}

// 检查录入格式是否正确
public boolean checkInputFormat(String itemno, String warehousingtime, String warehousenumber, String warehouseplace) {
// 自定义格式检查逻辑
// 返回 true 或 false

// 示例:检查itemno是否为8位数字
if (itemno.matches("\\d{8}")) {
return true;
} else {
return false;
}
}

public static void main(String[] args) {
WarehouseManagement warehouseManagement = new WarehouseManagement();
warehouseManagement.mainMenu();
}

}

标签:scanner,开学,String,System,测试,println,public,out
From: https://www.cnblogs.com/gjsgjs/p/17709692.html

相关文章

  • 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......
  • 开学测试代码
    importjdk.dynalink.beans.StaticClass;importjava.text.DateFormat;importjava.text.ParseException;importjava.text.SimpleDateFormat;importjava.util.Date;importjava.util.Scanner;publicclassWarehouseManagement{staticWarehouseInformation[]wareho......
  • 渗透测试基本流程以及nmap基本命令
    1首先确认目标2信息收集3漏洞扫描4漏洞验证5提权6清除痕迹信息收集可以从编写报告信息收集可以从系统版本信息,应用信息,服务信息,以及相关防护信息方面入手nmap基本命令:端口扫描SYN  nmap-sS+ipconnectnmap-sT+ipUDPnmap-sU+ipFINnmap-sF+ip扫描常见端口nmap......
  • 开学测试修改(9.17)
    packagehomework;publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStr......
  • 开学测试题分解步骤
    importjava.util.Scanner;//数据类WarehouseInformationclassWarehouseInformation{   privateStringproductId;   privateStringproductName;   privateStringsupplier;   privateStringentryDate;   privateintwarehouseNumber; ......
  • 开学测试题重写
    packagefile;importjava.util.Scanner;importjava.util.ArrayList;publicclassWarehouseManagement{publicstaticvoidmain(String[]args){ArrayList<WarehouseInformation>x=newArrayList<WarehouseInformation>();while(true......
  • 网络测试指标
    对网络设备和TCP/IP网络的检测主要包括以下基本技术指标。(1)吞吐量(Throughput)。吞吐量是指被测试设备或被测试系统在不丢包的情况下,能够达到的最大包转发速率。吞吐量测试是在每一对端口上,以全线速度(或测试设置中规定的速率)在测试设置规定的时间段内生成传输流。如果在任何端......
  • 课前测试优化
    石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版WarehouseInformation类商品信息类publicclassWarehouseInformation{privateStringitemno;//编码privateStringitemname;//商品名称privateStringsuppliername;//供货商名字privateStrin......
  • 渗透测试流程
    渗透测试概况一、网络渗透测试执行标准1、渗透测试的概念渗透测试(PenetrationTesting)是一种通过模拟攻击的技术与方法,挫败目标系统的安全控制措施并获得控制访问权的安全测试方法。网络渗透测试主要依据CVE(CommonVulnerabilitiesandExposures)已经发现的安全漏洞,模拟入......