首页 > 其他分享 >第一次测试修改后代码

第一次测试修改后代码

时间:2023-09-14 20:11:36浏览次数:43  
标签:String 代码 System wh 修改 Objects 测试 println out

软件包study

//包内java类   Main.class

package study;

import java.util.Objects;
import java.util.Scanner;

public abstract class Main {

    static WarehouseInformation[] wh = new WarehouseInformation[5];
    static int i=0;

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        wh[0] = new WarehouseInformation();
        wh[1] = new WarehouseInformation();
        wh[2] = new WarehouseInformation();
        wh[3] = new WarehouseInformation();
        wh[4] = new WarehouseInformation();


        boolean flag = true;
        while (flag) {

            menu();
            String ch = sc.nextLine();

            switch (ch) {

                case "1":
                    commodity_inbound();
                    break;

                case "2":
                    i=0;
                    modification();
                    break;

                case "3":
                    i=0;
                    commodity_outbound();
                    break;

                case "4":
                    i=0;
                    inventory();
                    break;

                case "5":
                    flag=false;
                    break;

                default:
                    System.out.println("选项不存在,请重新输入:");

            }

        }

    }


    //菜单
    public static void menu() {
        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("                    5、退出");

        System.out.println("**********************************************************");
    }

    //入库
    public static void commodity_inbound() {

        boolean sign = true;
        String Itemno = null, Itemname, Suppliername, Warehousingtime = null, Warehousenumber = null, Warehouseplace = null;
        int Itemnumber = 0;
        while (sign) {

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


            System.out.print("                 商品编号:");
            boolean flag = true;
            while (flag) {
                Itemno = sc.nextLine();
                if (Itemno.length() != 8) {
                    System.out.println("录入错误!");
                    System.out.print("                 商品编号:");
                } else flag = false;
            }



            System.out.print("                 商品名称:");
            Itemname = sc.nextLine();




            System.out.print("                 供货商信息:");
            Suppliername = sc.nextLine();




            System.out.print("                 入库时间:");
            flag = true;
            while (flag) {
                Warehousingtime = sc.nextLine();
                if (Warehousingtime.length() != 8) {
                    System.out.println("录入错误!");
                    System.out.print("                 入库时间:");
                } else flag = false;
            }




            System.out.print("                 存放仓库号:");
            flag = true;
            while (flag) {
                Warehousenumber = sc.nextLine();
                if (Warehousenumber.length() != 3) {
                    System.out.println("录入错误!");
                    System.out.print("                 存放仓库号:");
                } else flag = false;
            }




            System.out.print("                 存放位置信息:");
            flag = true;
            while (flag) {
                Warehouseplace = sc.nextLine();
                if (Warehouseplace.length() != 8) {
                    System.out.println("录入错误!");
                    System.out.print("                 存放位置信息:");
                } else flag = false;
            }





            System.out.print("                 入库商品数量:");
            Itemnumber = sc.nextInt();
            String useless=sc.nextLine();





            System.out.print("              该商品入库操作已完成,是否提交(Y/N):");
            String s = sc.nextLine();
            if (Objects.equals(s, "Y") || Objects.equals(s, "y")) {
                wh[i].setItemno(Itemno);
                wh[i].setItemname(Itemname);
                wh[i].setSuppliername(Suppliername);
                wh[i].setWarehousingtime(Warehousingtime);
                wh[i].setWarehousenumber(Warehousenumber);
                wh[i].setWarehouseplace(Warehouseplace);
                wh[i].setItemnumber(Itemnumber);
                i++;
                System.out.println("输入完成");
                sign = false;
            } else if (Objects.equals(s, "N") || Objects.equals(s, "n")) System.out.println("请重新输入");
        }
    }

    //修改
    public static void modification() {

        while (true) {

            System.out.println("***********************************************************");

            System.out.println("              石家庄铁道大学前进22软件开发有限公司");

            System.out.println("                  仓库管理系统2022版");

            System.out.println("***********************************************************");

            System.out.print("                请输入商品编号:");
            String s = sc.nextLine();

            System.out.println("***********************************************************");



            if(Objects.equals(s, "-1"))  break;

            int a = 0, i = 0;
            for (i = 0; i < wh.length; i++) {
                if (Objects.equals(s, wh[i].getItemno())) {
                    a = 1;
                    break;
                }
            }

            if (a == 0) System.out.println("库中没有该商品");

            else if (a == 1) {

                boolean sign = true;
                while (sign) {
                    String Itemno = null, Itemname, Suppliername, Warehousingtime = null, Warehousenumber = null, Warehouseplace = null;
                    int Itemnumber;

                    display(i);
                    System.out.print("             请选择需要修改的信息编号(1-7):");
                    int choose = sc.nextInt();
                    String useless=sc.nextLine();


                    switch (choose) {

                        case 1: {

                            System.out.print("             请输入修改后的商品编号:");

                            boolean flag = true;
                            while (flag) {
                                Itemno = sc.nextLine();
                                System.out.println("***********************************************************");

                                if (Itemno.length() != 8) {
                                    System.out.println("录入错误!");
                                    System.out.print("             请输入修改后的商品编号:");
                                } else flag = false;
                            }

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                                wh[i].setItemno(Itemno);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        case 2: {

                            System.out.print("             请输入修改后的商品名称:");
                            Itemname = sc.nextLine();
                            System.out.println("***********************************************************");

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                                wh[i].setItemname(Itemname);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        case 3: {

                            System.out.print("             请输入修改后的供货商信息:");
                            Suppliername = sc.nextLine();
                            System.out.println("***********************************************************");

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")){
                                wh[i].setSuppliername(Suppliername);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        case 4: {

                            System.out.print("             请输入修改后的入库时间:");


                            boolean flag = true;
                            while (flag) {
                                Warehousingtime = sc.nextLine();
                                System.out.println("***********************************************************");

                                if (Warehousingtime.length() != 8) {
                                    System.out.println("录入错误!");
                                    System.out.print("             请输入修改后的入库时间:");
                                } else flag = false;
                            }

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                                wh[i].setWarehousingtime(Warehousingtime);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }

                        case 5: {

                            System.out.print("             请输入修改后的存放仓库号:");

                            boolean flag = true;
                            while (flag) {
                                Warehousenumber = sc.nextLine();
                                System.out.println("***********************************************************");

                                if (Warehousenumber.length() != 3) {
                                    System.out.println("录入错误!");
                                    System.out.print("             请输入修改后的存放仓库号:");
                                } else flag = false;
                            }

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                                wh[i].setWarehousingtime(Warehousenumber);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        case 6: {

                            System.out.print("             请输入修改后的存放位置信息:");

                            boolean flag = true;
                            while (flag) {
                                Warehouseplace = sc.nextLine();
                                System.out.println("***********************************************************");

                                if (Warehouseplace.length() != 8) {
                                    System.out.println("录入错误!");
                                    System.out.print("             请输入修改后的存放位置信息:");
                                } else flag = false;
                            }

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")){
                                wh[i].setWarehouseplace(Warehouseplace);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        case 7: {

                            System.out.print("             请输入修改后的入库商品数量:");
                            Itemnumber = sc.nextInt();
                            System.out.println("***********************************************************");

                            System.out.println("该商品信息修改操作已完成,是否提交(Y/N)");
                            String c=sc.nextLine();
                            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                                wh[i].setItemnumber(Itemnumber);
                                System.out.println("修改完成");
                            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                                System.out.println("放弃修改");
                            }
                            break;
                        }


                        default: {
                            System.out.println("该选项不存在");
                            sign=false;
                        }
                    }
                }

            }
        }
    }

    //出库
    public static void commodity_outbound() {
        System.out.println("***********************************************************");

        System.out.println("              石家庄铁道大学前进22软件开发有限公司");

        System.out.println("                  仓库管理系统2022版");

        System.out.println("***********************************************************");

        System.out.print("                 请输入商品编号:");
        String s = sc.nextLine();

        System.out.println("***********************************************************");


        int a = 0, i = 0;
        for (i = 0; i < wh.length; i++) {
            if (Objects.equals(s, wh[i].getItemno())) {
                a = 1;
                break;
            }
        }

        if (a == 0) System.out.println("库中没有该商品");

        else if (a == 1) {

           display(i);

            String shipmenttime = null;
            int outnumber=0;


            System.out.print("                 出库时间:");
            boolean flag = true;
            while (flag) {
                shipmenttime = sc.nextLine();
                if (shipmenttime.length() != 8) {
                    System.out.println("录入错误!");
                    System.out.print("                 出库时间:");
                }else if(shipmenttime.compareTo(wh[i].getWarehousingtime())<=0){
                    System.out.println("录入错误!");
                    System.out.print("                 出库时间:");
                }else flag = false;
            }

            System.out.print("                 出库商品数量:");
            flag = true;
            while (flag) {
                outnumber = sc.nextInt();
                String useless=sc.nextLine();
                if(outnumber>wh[i].getItemnumber()){
                    System.out.println("录入错误!");
                    System.out.print("                 出库商品数量:");
                }else flag = false;
            }

            System.out.println("***********************************************************");

            System.out.print("              该商品出库操作已完成,是否提交(Y/N):");
            String c = sc.nextLine();
            if (Objects.equals(c, "Y") || Objects.equals(c, "y")) {
                wh[i].setShipmenttime(shipmenttime);
                wh[i].setOutnumber(outnumber);
                System.out.println("保存完成");
                //sign=false;
            } else if (Objects.equals(c, "N") || Objects.equals(c, "n")) {
                System.out.println("放弃保存");
            }
        }
    }

    //输出
    public static void inventory(){
        System.out.println("***********************************************************");

        System.out.println("              石家庄铁道大学前进22软件开发有限公司");

        System.out.println("                  仓库管理系统2022版");

        System.out.println("***********************************************************");
        for(int i=0;i< wh.length;i++){
            System.out.println("商品编号:"+wh[i].getItemno()+"、商品名称"+wh[i].getItemname()+"、库存数量"+(wh[i].getItemnumber()-wh[i].getOutnumber()));
        }
        System.out.println("***********************************************************");
    }

    public static void display(int i){
        System.out.println("***********************************************************");

        System.out.println("              石家庄铁道大学前进22软件开发有限公司");

        System.out.println("                  仓库管理系统2022版");

        System.out.println("***********************************************************");

        System.out.print("                 商品编号:");
        System.out.println(wh[i].getItemno());

        System.out.print("                 商品名称:");
        System.out.println(wh[i].getItemname());

        System.out.print("                 供货商信息:");
        System.out.println(wh[i].getSuppliername());

        System.out.print("                 入库时间:");
        System.out.println(wh[i].getWarehousingtime());

        System.out.print("                 存放仓库号:");
        System.out.println(wh[i].getWarehousenumber());

        System.out.print("                 存放位置信息:");
        System.out.println(wh[i].getWarehouseplace());

        System.out.print("                 入库商品数量:");
        System.out.println(wh[i].getItemnumber());


    }

}
//包内java类 WarehouseInformation.class

package study;

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(){
        this.itemno = " ";
        this.itemname = " ";
        this.suppliername = " ";
        this.warehousingtime = " ";
        this.shipmenttime = " ";
        this.warehousenumber = " ";
        this.warehouseplace = " ";
        this.itemnumber = 0 ;
        this.outnumber = 0 ;
    }
    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 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;
    }
}

 

标签:String,代码,System,wh,修改,Objects,测试,println,out
From: https://www.cnblogs.com/leapssisbird/p/17703338.html

相关文章

  • app测试日常踩坑——新老版本共用缓存问题
    需求:在测一个页面,老版本就存在的一个页面(多个模块,一个接口分成三次请求返回),但是新版本要新增一个模块。老的页面的实现方式是页面直接读取redis数据(还有其他逻辑,方便解释暂时这样说),截取模块的方式来分接口返回,新增的一个模块是要放在中间。方案:方案是沿用老的redis缓存,在老得缓存......
  • app测试日常踩坑——gocache缓存的过期时间和生成间隔问题
    问题:自动化监控平台添加的分类详情页的接口报错,分类详情页校验失败,看到的错误信息是接口响应错误,信息如下:{"errors":{"id":"0","code":"44010102","level":"1","status":"200","title":"参数错误","popup......
  • 测试部署的微服务
            ......
  • 以太坊数据存证性能与膨胀率测试
    我们基于区块链在企业中的应用最广泛的就是“存证”功能需求,这是利用了区块链不可篡改和数据共享的特点,存证的业务数据一方面可以保证留痕和追溯,另一方面也实现了多个节点(如果部署在不同企业和部门)之间的数据共享。如果要实现存证,我们最关心并不是图灵完备,也不是去中心化,而是存证......
  • 自助式自动重启测试
    importos,sys,shutil,webbrowserimporttkinterastkfromtkinterimportscrolledtext,END,Y,LEFT,BOTH,messageboxsys.path.append("..")classVideo(object):def__init__(self,master):self.master=masterself.adict={}......
  • 数据库更新效率测试
    有个项目记录采集点的实时数据(mysql5.7),约5000条记录,在C#的DataTable更新好后,一次性Update到表中,但速度非常慢要4分钟左右,但程序定时更新为5分钟,经常超时,也找不到好的办法,最后把这个表改为Memory引擎后速度提高到5秒左右,总算解决了问题。因为此,在本机做了些测试,为以后的数据库选型......
  • crypto 加解密库简介与测试【GO 常用的库】
    〇、前言GO语言的标准库crypto提供了一组用于加密和解密的包,包括对称加密、哈希函数、数字签名、随机数生成等功能。在日常开发中,通过使用这些库,可以确保数据的安全性和完整性。对于使用频率比较高的东西,还是要汇总一下用来备查。一、md5加密md5包实现了RFC1321中定义......
  • 释放潜能!RunnerGo:性能测试的全新视角
    在数字化时代,性能测试已成为企业持续发展的关键一环。但面对繁杂的工具和流程,很多企业却陷入了无从选择的困境。现在,一款名为RunnerGo的全新性能测试工具正悄然崭露头角。RunnerGo,一款由国内开发者自主研发的全栈式性能测试平台,以其独特的视角和强大的功能,彻底改变了传统的性能测试......
  • mybatisplus代码生成器 死活连接不上
    dburl改一下:jdbc:mysql://124.220.134.111:3306/content?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai    &useSSL=false一定要加这个鬼东西沃日......
  • 释放潜能!RunnerGo:性能测试的全新视角
    在数字化时代,性能测试已成为企业持续发展的关键一环。但面对繁杂的工具和流程,很多企业却陷入了无从选择的困境。现在,一款名为RunnerGo的全新性能测试工具正悄然崭露头角。RunnerGo,一款由国内开发者自主研发的全栈式性能测试平台,以其独特的视角和强大的功能,彻底改变了传统的性能测......