首页 > 其他分享 >9.15课堂测试(已在文件发表)

9.15课堂测试(已在文件发表)

时间:2023-09-17 21:38:00浏览次数:124  
标签:String 9.15 System sc 测试 println 课堂 public out

WarehouseInformation.java:   package 仓库管理系统;

public class WarehouseInformation {
private String itemno; //表示商品编号(有8 位数字组成)
private String itemname; //表示商品名称
private String suppliername; //表示供货商名称
private String warehousingtime; //表示入库时间,长度八位
private String shipmenttime; //表示出库时间,长度八位
private String warehousenumber; //表示仓库编号,长度三位
private String warehouseplace; //表示存放商品的具体位置,长度八位数字XXXXYYZZ,其中XXXX表示货架号,YY表示货架的层号,ZZ表示存放在该货架该层的商品顺序号
private int itemnumber; //表示入库商品的数量
private int outnumber = 0; //表示出库商品的数量

public WarehouseInformation() {
}

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;
}
// public WarehouseInformation(String itemno, String itemname, String suppliername){
// this.itemno = itemno;
// this.itemname = itemname;
// this.suppliername = suppliername;
// }
/**
* 获取
* @return itemno
*/
public String getItemno() {
return itemno;
}

/**
* 设置
* @param itemno
*/
public void setItemno(String itemno) {
this.itemno = itemno;
}

/**
* 获取
* @return itemname
*/
public String getItemname() {
return itemname;
}

/**
* 设置
* @param itemname
*/
public void setItemname(String itemname) {
this.itemname = itemname;
}

/**
* 获取
* @return suppliername
*/
public String getSuppliername() {
return suppliername;
}

/**
* 设置
* @param suppliername
*/
public void setSuppliername(String suppliername) {
this.suppliername = suppliername;
}

/**
* 获取
* @return warehousingtime
*/
public String getWarehousingtime() {
return warehousingtime;
}

/**
* 设置
* @param warehousingtime
*/
public void setWarehousingtime(String warehousingtime) {
this.warehousingtime = warehousingtime;
}

/**
* 获取
* @return shipmenttime
*/
public String getShipmenttime() {
return shipmenttime;
}

/**
* 设置
* @param shipmenttime
*/
public void setShipmenttime(String shipmenttime) {
this.shipmenttime = shipmenttime;
}

/**
* 获取
* @return warehousenumber
*/
public String getWarehousenumber() {
return warehousenumber;
}

/**
* 设置
* @param warehousenumber
*/
public void setWarehousenumber(String warehousenumber) {
this.warehousenumber = warehousenumber;
}

/**
* 获取
* @return warehouseplace
*/
public String getWarehouseplace() {
return warehouseplace;
}

/**
* 设置
* @param warehouseplace
*/
public void setWarehouseplace(String warehouseplace) {
this.warehouseplace = warehouseplace;
}

/**
* 获取
* @return itemnumber
*/
public int getItemnumber() {
return itemnumber;
}

/**
* 设置
* @param itemnumber
*/
public void setItemnumber(int itemnumber) {
this.itemnumber = itemnumber;
}

/**
* 获取
* @return outnumber
*/
public int getOutnumber() {
return outnumber;
}

/**
* 设置
* @param outnumber
*/
public void setOutnumber(int outnumber) {
this.outnumber += outnumber;
}

public void show(){
System.out.println("1.商品编号:" + this.itemno);
System.out.println("2.商品名称:" +this.itemname );
System.out.println("3.供货商信息:" + this.suppliername);
System.out.println("4.入库时间:" + this.warehousingtime);
System.out.println("5.存放仓库号:" + this.warehousenumber);
System.out.println("6.存放位置信息:" + this.warehouseplace);
System.out.println("7.入库商品数量:" + this.itemnumber);
}

// public String toString() {
// return "WarehouseInformation{itemno = " + itemno + ", itemname = " + itemname + ", suppliername = " + suppliername + ", warehousingtime = " + warehousingtime + ", shipmenttime = " + shipmenttime + ", warehousenumber = " + warehousenumber + ", warehouseplace = " + warehouseplace + ", itemnumber = " + itemnumber + ", outnumber = " + outnumber + "}";
// }
}     WarehouseInformation.java
package 仓库管理系统;

import java.util.Scanner;

public class WarehouseManagement {
public static void main(String[] args) {
WarehouseInformation[] s = new WarehouseInformation[5];
WarehouseInformation s1 = new WarehouseInformation("20223766",""郑盾,"郑盾_","00000000","00000001","001","00000000",100,10);
WarehouseInformation s2 = new WarehouseInformation("20223767","李伯禧","李伯禧_","00000001","00000002","002","00000001",100,20);
WarehouseInformation s3 = new WarehouseInformation("20223768","李健龙","李健龙_","00000002","00000003","005","00000002",100,30);
WarehouseInformation s4 = new WarehouseInformation("20223769",""王梦硕,"王梦硕_","00000003","00000004","004","00000003",100,40);
s[0] = s1;
s[1] = s2;
s[2] = s3;
s[3] = s4;
WarehouseInformation s5 = new WarehouseInformation();
s[4] = s5;
Scanner sc = new Scanner(System.in);
while (true){
Display_homepage();
int n = sc.nextInt();
switch (n) {
case 1 -> {Warehouse(s);}
case 2 -> {Infomod(s);}
case 3 -> {Outbound(s);}
case 4 -> {Show(s);return;}
default -> {System.out.println("该选项不存在");}
}
}
}
public static void Display_homepage(){
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
1、商品入库管理
2、商品信息修改
3、商品出库管理
4、仓库盘点管理
**********************************************************
""");

public static void page() {
System.out.println("""
***********************************************************
石家庄铁道大学前进22软件开发有限公司
仓库管理系统2022版
***********************************************************
""");


public static void Warehouse(WarehouseInformation[] s){
page();
String no;
String name;
String supplier;
String wtime;
String wnum;
String place;
int num;
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("商品编号:");
no = sc.next();
System.out.print("商品名称:");
name = sc.next();
System.out.print("供货商信息:");
supplier = sc.next();
System.out.print("入库时间:");
wtime = sc.next();
System.out.print("存放仓库号:");
wnum = sc.next();
System.out.print("存放位置信息:");
place = sc.next();
System.out.print("入库商品数量:");
num = sc.nextInt();
System.out.println("***********************************************************");
if(no.length() == 8 && wtime.length() == 8 && wnum.length() == 3 && place.length() == 8){
break;
}
System.out.println("录入错误");
}
page();
System.out.println("商品编号:" + no);
System.out.println("商品名称:" + name);
System.out.println("供货商信息:" + supplier);
System.out.println("入库时间:" + wtime);
System.out.println("存放仓库号:" + wnum);
System.out.println("存放位置信息:" + place);
System.out.println("入库商品数量:" + num);
System.out.println("该商品入库操作已完成,是否提交(Y/N)");
String str = sc.next();
if(str.equals("Y")) {
s[4].setItemno(no);
s[4].setItemname(name);
s[4].setSuppliername(supplier);
s[4].setWarehousingtime(wtime);
s[4].setWarehousenumber(wnum);
s[4].setWarehouseplace(place);
s[4].setItemnumber(num);
}

} //入库管理

public static void Infomod(WarehouseInformation[] s){
page();
String no;
String name;
String supplier;
String wtime;
String wnum;
String place;
int num;
int flag = 0;
Scanner sc = new Scanner(System.in);
System.out.print("请输入商品编号:");
String str = sc.next();
System.out.println("**********************************************************");
for (int i = 0; i < s.length; i++) {
if(s[i].getItemno().equals(str)){
flag = 1;
page();
s[i].show();
System.out.print("请选择需要修改的信息编号:");
int n = sc.nextInt();
switch (n){
case 1->{
System.out.print("请输入修改后的商品编号:");
no = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemno(no);
}
}
case 2->{
System.out.print("请输入修改后的商品名称:");
name = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemname(name);
}
}
case 3->{
System.out.print("请输入修改后的供货商信息:");
supplier = sc.next();
String str1 = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
if(str1.equals("Y")) {
s[i].setSuppliername(supplier);
}
}
case 4->{
System.out.print("请输入修改后的入库时间:");
wtime = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehousingtime(wtime);
}
}
case 5->{
System.out.print("请输入修改后的存放仓库号:");
wnum = sc.next();

System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehousenumber(wnum);
}
}
case 6->{
System.out.print("请输入修改后的存放位置信息:");
place = sc.next();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setWarehouseplace(place);
}
}
case 7->{
System.out.print("请输入修改后的商品数量:");
num = sc.nextInt();
System.out.println("该商品修改操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setItemnumber(num);
}
}
default -> {
System.out.println("该选项不存在");
}
}
break;
}
}
if(flag == 0){
Infomod(s);
}

} //信息修改

public static void Outbound(WarehouseInformation[] s){
page();
int flag = 0;
String stime;
int onum;
Scanner sc = new Scanner(System.in);
System.out.print("请输入商品编号:");
String str = sc.next();
System.out.println("**********************************************************");
for (int i = 0; i < s.length; i++) {
if(s[i].getItemno().equals(str)){
flag = 1;
page();
s[i].show();
while(true) {
System.out.print("出库时间:");
stime = sc.next();
System.out.print("出库数量:");
onum = sc.nextInt();
System.out.println("**********************************************************");
if (onum <= (s[i].getItemnumber() - s[i].getOutnumber()) && stime.length() == 8 && (Integer.parseInt(stime) > Integer.parseInt(s[i].getWarehousingtime()))) {
break;
}
}
System.out.println("该商品出库操作已完成,是否提交(Y/N)");
String str1 = sc.next();
if(str1.equals("Y")) {
s[i].setOutnumber(onum);
}
break;
}
}
if(flag == 0){
Outbound(s);
}

} //出库管理

public static void Show(WarehouseInformation[] s){
page();
for (int i = 0; i < s.length; i++) {
System.out.println(i + 1 + "、 商品编号: " + s[i].getItemno() + "、商品名称: " + s[i].getItemname() + "、库存数量: " + (s[i].getItemnumber() - s[i].getOutnumber()));
}
System.out.println("…………………………………………………");
System.out.println("**********************************************************");
} //仓库盘点
}

标签:String,9.15,System,sc,测试,println,课堂,public,out
From: https://www.cnblogs.com/kuandong24/p/17709847.html

相关文章

  • Postman测试金蝶云星空Webapi【协同开发云下的本地环境】
    业务背景:基于金蝶云星空提供的接口测试,交付之前或者联调之前开发者先自测,即使纠错,提高效率。  大致流程:先请求登录接口,获得token后再请求标准webapi或者自定义接口,这样上下文才不会空。 说明: 金蝶的接口格式一般为:http://ServerIp/K3Cloud/接口命名空间.接口实现类名......
  • 使用TestContainers在Docker中进行集成测试
    现代软件应用很少独立工作。典型的应用程序会与几个外部系统进行通信,如:数据库、消息系统、缓存提供商其他第三方服务。你应该编写测试确保一切正常运行。单元测试有助于隔离地测试业务逻辑,不涉及任何外部服务。它们易于编写并提供几乎即时的反馈。有了单元测试还不够,集......
  • 开学测试
    publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStringwarehouseplac......
  • 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......