首页 > 其他分享 >开学测试修改(9.17)

开学测试修改(9.17)

时间:2023-09-17 19:15:50浏览次数:40  
标签:开学 String 9.17 list System break 测试 println out

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

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() {
}
}

*************************************************************************************************************************************************************************************************

-----------------------------------------------------------------------------------分界线---------------------------------------------------------------------------------------------------------
*************************************************************************************************************************************************************************************************
package homework;
import java.util.ArrayList;
import java.util.Scanner;

public class WarehouseManagement {
public static void main(String[] args) {
ArrayList<WarehouseInformation> list = new ArrayList<>();
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("\t"+"1、商品入库管理");
System.out.println("\t"+"2、商品信息修改");
System.out.println("\t"+"3、商品出库管理");
System.out.println("\t"+"4、仓库盘点管理");
System.out.println("\t"+"5、退出");
System.out.println("***********************************************************");
loop:while (true) {
System.out.println("请选择:");
Scanner sc = new Scanner(System.in);
String num = sc.next();
switch(num) {
case "1":
System.out.println("已选择商品入库管理");
addw(list);
break;
case "2":
System.out.println("已选择商品信息修改");
changew(list);
break;
case "3":
System.out.println("已选择商品出库管理");
//outw(list);
break;
case "4":
System.out.println("已选择仓库盘点管理");
panDianw(list);
break;
case "5":
System.out.println("已选择退出");
break loop;
default:
System.out.println("没有这个选项");
break;
}
}
}
//商品入库管理
public static void addw(ArrayList<WarehouseInformation> list) {
loop0: while (true) {
WarehouseInformation w = new WarehouseInformation();
Scanner sc = new Scanner(System.in);
System.out.println("商品编号:");
String itemno = sc.next();
boolean flag1 = judge(list,itemno);
if(flag1){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
System.out.println("商品名称:");
String itemname = sc.next();
w.setItemname(itemname);
System.out.println("供货商信息:");
String suppliername = sc.next();
w.setSuppliername(suppliername);
System.out.println("入库时间:");
String warehousingtime = sc.next();
boolean flag2 = judge(list,warehousingtime);
if(flag2){
w.setWarehousingtime(warehousingtime);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("存放仓库号:");
String warehousenumber = sc.next();
boolean flag3 = judge(list,warehousenumber);
if(flag3){
w.setWarehousenumber(warehousenumber);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("存放位置信息:");
String warehouseplace = sc.next();
boolean flag4 = judge(list,warehouseplace);
if(flag4){
w.setWarehouseplace(warehouseplace);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
System.out.println("入库商品数量:");
int itemnumber = sc.nextInt();
w.setItemnumber(itemnumber);
System.out.println("保存完成");
System.out.println("***********************************************************");
System.out.println("\t" + "石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t" + " 仓库管理系统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("该商品入库操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break loop0;
}
else{
break loop0;
}
}
}
//商品信息修改
public static void changew(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
WarehouseInformation w=new WarehouseInformation();
Scanner sc =new Scanner(System.in);
String itemno=null;
while (true) {
System.out.print("请输入商品编号:");
itemno = sc.next();
boolean flag1 = judge(list,itemno);
if(flag1){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
boolean flag = contains(list, itemno);
if (flag) {
System.out.println("商品编号不存在,请重新输入:");
}
else {
w.setItemno(itemno);
loop1: for (int i = 0; i < list.size(); i++){
WarehouseInformation war = list.get(i);
System.out.println("***********************************************************");
System.out.println("\t" + "石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t" + " 仓库管理系统2022版");
System.out.println("***********************************************************");
System.out.println("商品编号:" + war.getItemno());
System.out.println("商品名称:" + war.getItemname());
System.out.println("供货商信息:" + war.getSuppliername());
System.out.println("入库时间:" + war.getWarehousingtime());
System.out.println("存放仓库号:" + war.getWarehousenumber());
System.out.println("存放位置信息:" + war.getWarehouseplace());
System.out.println("入库商品数量:" + war.getItemnumber());
loop2:while (true) {
System.out.println("请选择需要修改的信息编号(1-7):");
int num = sc.nextInt();
switch(num){
case 1:System.out.print("请输入修改后的商品编号:");
itemno = sc.next();
boolean flag11 = judge(list,itemno);
if(flag11){
w.setItemno(itemno);
break;
}
else{
System.out.println("格式错误,请重新输入");
}
break loop2;
case 2:System.out.print("请输入修改后的商品名称:");
String itemname = sc.next();
w.setItemname(itemname);
break loop2;
case 3:System.out.print("请输入修改后的供货商信息:");
String suppliername = sc.next();
w.setSuppliername(suppliername);
break loop2;
case 4:System.out.print("请输入修改后的入库时间:");
String warehousingtime = sc.next();
boolean flag22 = judge(list,warehousingtime);
if(flag22){
w.setWarehousingtime(warehousingtime);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 5:System.out.print("请输入修改后的存放仓库号:");
String warehousenumber = sc.next();
boolean flag33 = judge(list,warehousenumber);
if(flag33){
w.setWarehousenumber(warehousenumber);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 6:System.out.print("请输入修改后的存放位置信息:");
String warehouseplace = sc.next();
boolean flag44 = judge(list,warehouseplace);
if(flag44){
w.setWarehouseplace(warehouseplace);
break;
}
else {
System.out.println("格式错误,请重新输入");
}
break loop2;
case 7:System.out.print("请输入修改后的入库商品数量:");
int itemnumber = sc.nextInt();
w.setItemnumber(itemnumber);
break loop2;
default:
System.out.println("该选项不存在");
}
}
System.out.println("该商品修改操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break loop1;
}
else{
break loop1;
}
}
break;
}
}

}
//商品出库管理
public static void outw(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
WarehouseInformation w=new WarehouseInformation();
Scanner sc =new Scanner(System.in);
String itemno=null;
loop02:while (true) {
System.out.print("请输入商品编号:");
itemno = sc.next();
boolean flag = contains(list, itemno);
if (flag) {
System.out.println("商品编号不存在,请重新输入:");
}
else {
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
w.setItemno(itemno);
System.out.println("商品编号:" + war.getItemno());
System.out.println("商品名称:" + war.getItemname());
System.out.println("供货商信息:" + war.getSuppliername());
System.out.println("入库时间:" + war.getWarehousingtime());
System.out.println("存放仓库号:" + war.getWarehousenumber());
System.out.println("存放位置信息:" + war.getWarehouseplace());
System.out.println("入库商品数量:" + war.getItemnumber());
break;
}
int num;
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
System.out.println("请输入出库数量:");
num = sc.nextInt();
if (num <= war.getItemnumber()) {
countWarehouse(num,list);
break loop02;
}
else {
System.out.println("出库数量错误!");
}
}
}
System.out.println("该商品修改操作已完成,是否提交(1/-1)");
int c=sc.nextInt();
if (c==1) {
list.add(w);
System.out.println("保存成功");
System.out.println("**********************************************************");
break ;
}
else{
break ;
}
}
}
}
//仓库盘点管理
public static void panDianw(ArrayList<WarehouseInformation> list){
System.out.println("***********************************************************");
System.out.println("\t"+"石家庄铁道大学前进22软件开发有限公司");
System.out.println("\t"+" 仓库管理系统2022版");
System.out.println("***********************************************************");
for (int i = 1; i < list.size(); i++){
WarehouseInformation war = list.get(i);
int x=war.getItemnumber()-war.getOutnumber();
System.out.println(i+"、"+"商品编号:"+war.getItemno()+"、"+"商品名称:"+war.getItemname()+"、"+"库存数量:"+x);
}
System.out.println("***********************************************************");
}

public static boolean contains(ArrayList<WarehouseInformation> list ,String itemno){
for (int i = 0; i < list.size(); i++) {
WarehouseInformation war = list.get(i);
String sid =war.getItemno();
if(sid.equals(itemno)){
return false;
}
}
return true;
}
public static boolean judge(ArrayList<WarehouseInformation> list,String str){
if(str.length() != 8 && str.length() !=3){
return false;
}else{
for (int i = 0; i < str.length(); i++) {
if(!(str.charAt(i)<='9' && str.charAt(i)>= '0')){
return false;
}
}
}
return true;
}

public static void countWarehouse(int num,ArrayList<WarehouseInformation> list){
int snum = 0;
for (int i = 0; i < 1; i++) {
WarehouseInformation war = list.get(i);
snum = war.getItemnumber() - num;
System.out.println("剩余库存数为:" + snum);
war.setItemnumber(snum);
}
}
}

标签:开学,String,9.17,list,System,break,测试,println,out
From: https://www.cnblogs.com/HD-Kudu-2219/p/17709466.html

相关文章

  • 9.17
    packagetest;publicclassWarehouseInformation{privateStringitemno;//编号,八位数字privateStringitemname;//名称privateStringsuppliername;//供货商privateStringwarehousingtime;//入库时间,八位数字privateStringshipmenttime;//出库时间,......
  • 开学测试题分解步骤
    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......
  • 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的芯片要用多少片......
  • 网络测试指标
    对网络设备和TCP/IP网络的检测主要包括以下基本技术指标。(1)吞吐量(Throughput)。吞吐量是指被测试设备或被测试系统在不丢包的情况下,能够达到的最大包转发速率。吞吐量测试是在每一对端口上,以全线速度(或测试设置中规定的速率)在测试设置规定的时间段内生成传输流。如果在任何端......
  • 课前测试优化
    石家庄铁道大学前进22软件开发有限公司仓库管理系统2022版WarehouseInformation类商品信息类publicclassWarehouseInformation{privateStringitemno;//编码privateStringitemname;//商品名称privateStringsuppliername;//供货商名字privateStrin......
  • 渗透测试流程
    渗透测试概况一、网络渗透测试执行标准1、渗透测试的概念渗透测试(PenetrationTesting)是一种通过模拟攻击的技术与方法,挫败目标系统的安全控制措施并获得控制访问权的安全测试方法。网络渗透测试主要依据CVE(CommonVulnerabilitiesandExposures)已经发现的安全漏洞,模拟入......
  • 如何使用 jest 测试使用 axios 的 httpClient?
    要使用Jest测试使用axios的httpClient,您可以使用Jest提供的模拟功能来伪造对外部API的请求和响应。下面是一个示例测试的代码:首先,安装所需的依赖:npminstallaxiosaxios-mock-adapterjest--save-dev然后,创建一个名为httpService.test.js的测试文件,编写以下代码:importaxiosfrom......
  • 开学考试
    开学考试代码重写源代码:importjava.util.Scanner;//数据类WarehouseInformationclassWarehouseInformation{   privateStringproductId;   privateStringproductName;   privateStringsupplier;   privateStringentryDate;   privatei......