首页 > 其他分享 >9.16

9.16

时间:2023-09-16 13:45:13浏览次数:30  
标签:arr String 9.16 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) {
            super();
            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;
        }


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

public class WarehouseManagement {
    public static void main(String[] args) {
        int choice;
        Scanner sc = new Scanner(System.in);
        WarehouseInformation[] arr = new WarehouseInformation[5];
        arr[0] = new WarehouseInformation("00000001", "0", "0", "0", "0", "0", "0", 30, 0);
        arr[1] = new WarehouseInformation("0", "0", "0", "0", "0", "0", "0", 0, 0);
        arr[2] = new WarehouseInformation("0", "0", "0", "0", "0", "0", "0", 0, 0);
        arr[3] = new WarehouseInformation("0", "0", "0", "0", "0", "0", "0", 0, 0);
        arr[4] = new WarehouseInformation("0", "0", "0", "0", "0", "0", "0", 0, 0);
        while (true) {
            menu();
            System.out.println("请输入你的选择:");
            choice = sc.nextInt();
            switch (choice) {
                case 1: {
                    in(arr);
                    break;
                }
                case 2: {
                    xiu(arr);
                    break;
                }
                case 3: {
                    chuku(arr);
                    break;
                }
                case 4: {
                    chaxun(arr);
                    break;
                }
                default: {
                    System.out.println("改选项不存在");
                    break;
                }
            }

        }
    }

    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("**********************************************************");
    }

    public static void in(WarehouseInformation[] arr) {
        Scanner s = new Scanner(System.in);
        String no;
        String name;
        String information;
        String time1;
        String wnumber;
        String wspace;
        char c;
        while (true) {
            while (true) {
                System.out.println("请输入商品编码");
                no = s.next();
                System.out.println("请输入商品名称");
                name = s.next();
                System.out.println("请输入供货商信息");
                information = s.next();
                System.out.println("请输入入库时间");
                time1 = s.next();
                System.out.println("请输入存放仓库号");
                wnumber = s.next();
                System.out.println("请输入存放位置");
                wspace = s.next();
                if ((no.length() == 8) && (time1.length() == 8) && (wnumber.length() == 3) && (wspace.length() == 8)) {
                    System.out.println("***********************************************************");
                    System.out.println("           石家庄铁道大学前进22软件开发有限公司");
                    System.out.println("                  仓库管理系统2022版");
                    System.out.println("***********************************************************");
                    System.out.println("                   商品编号:" + no);
                    System.out.println("                 商品名称:" + name);
                    System.out.println("             供货商信息:" + information);
                    System.out.println("                    入库时间:" + time1);
                    System.out.println("                     存放仓库号:" + wnumber);
                    System.out.println("                  存放位置信息:" + wspace);
                    System.out.println("                   入库商品数量:100");
                    System.out.println("**********************************************************");
                    break;
                } else {
                    System.out.println("录入错误");
                }
            }
            System.out.println("***********************************************************");
            System.out.println("           石家庄铁道大学前进22软件开发有限公司");
            System.out.println("                  仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("                   商品编号:" + no);
            System.out.println("                 商品名称:" + name);
            System.out.println("             供货商信息:" + information);
            System.out.println("                    入库时间:" + time1);
            System.out.println("                     存放仓库号:" + wnumber);
            System.out.println("                  存放位置信息:" + wspace);
            System.out.println("                   入库商品数量:100");
            System.out.println("           该商品入库操作已完成,是否提交(Y/N)");
            System.out.println("**********************************************************");
            c = s.next().charAt(0);
            if (c == 'Y') {
                for (int i = 0; i < 5; i++) {
                    if (arr[i].getItemno().equals("0")) {
                        arr[i].setItemno(no);
                        arr[i].setItemname(name);
                        arr[i].setSuppliername(information);
                        arr[i].setWarehousingtime(time1);
                        arr[i].setWarehousenumber(wnumber);
                        arr[i].setWarehouseplace(wspace);
                        arr[i].setItemnumber(100);
                        System.out.println("信息保存成功!");
                        return;
                    }
                }
            }
        }

    }

    public static void display(int i, WarehouseInformation[] arr, int choice) {
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学前进22软件开发有限公司");
        System.out.println("                  仓库管理系统2022版");
        System.out.println("***********************************************************");
        System.out.println("                 1、商品编号:" + arr[i].getItemno());
        System.out.println("              2、商品名称:" + arr[i].getItemname());
        System.out.println("          3、供货商信息:" + arr[i].getSuppliername());
        System.out.println("                4、入库时间:" + arr[i].getWarehousingtime());
        System.out.println("                 5、存放仓库号:" + arr[i].getWarehousenumber());
        System.out.println("               6、存放位置信息:" + arr[i].getWarehouseplace());
        System.out.println("                7、入库商品数量:" + arr[i].getItemnumber());
        System.out.println("            请选择需要修改的信息编号(1-7):" + choice);
        System.out.println("           请输入修改后的商品编号:");
        System.out.println("**********************************************************");
    }

    public static void xiu(WarehouseInformation[] arr) {
        Scanner s1 = new Scanner(System.in);
        String no1;
        String name;
        String information;
        String time1;
        String wnumber;
        String wspace;
        int number;
        int hao;
        int count = 0;
        char c;
        while (true) {
            System.out.println("***********************************************************");
            System.out.println("           石家庄铁道大学前进22软件开发有限公司");
            System.out.println("                  仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("              请输入商品编号:");
            System.out.println("**********************************************************");
            String no;
            no = s1.next();
            for (int i = 0; i < 5; i++) {
                if (no.equals(arr[i].getItemno())) {
                    count++;
                    System.out.println("***********************************************************");
                    System.out.println("           石家庄铁道大学前进22软件开发有限公司");
                    System.out.println("                  仓库管理系统2022版");
                    System.out.println("***********************************************************");
                    System.out.println("                 1、商品编号:" + arr[i].getItemno());
                    System.out.println("              2、商品名称:" + arr[i].getItemname());
                    System.out.println("          3、供货商信息:" + arr[i].getSuppliername());
                    System.out.println("                4、入库时间:" + arr[i].getWarehousingtime());
                    System.out.println("                 5、存放仓库号:" + arr[i].getWarehousenumber());
                    System.out.println("               6、存放位置信息:" + arr[i].getWarehouseplace());
                    System.out.println("                7、入库商品数量:" + arr[i].getItemnumber());
                    System.out.println("            请选择需要修改的信息编号(1-7):");
                    System.out.println("**********************************************************");
                    hao = s1.nextInt();
                    switch (hao) {
                        case 1: {
                            display(i, arr, 1);
                            no1 = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setItemno(no1);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 2: {
                            display(i, arr, 2);
                            name = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setItemname(name);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 3: {
                            display(i, arr, 3);
                            information = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setSuppliername(information);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 4: {
                            display(i, arr, 4);
                            time1 = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setWarehousingtime(time1);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 5: {
                            display(i, arr, 5);
                            wnumber = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setWarehousenumber(wnumber);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 6: {
                            display(i, arr, 6);
                            wspace = s1.next();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setWarehouseplace(wspace);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        case 7: {
                            display(i, arr, 7);
                            number = s1.nextInt();
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s1.next().charAt(0);
                            if (c == 'Y') {
                                arr[i].setItemnumber(number);
                                System.out.println("信息保存成功!");
                            } else {
                                return;
                            }
                            break;
                        }
                        default: {
                            System.out.println("该选项不存在");
                            return;
                        }
                    }
                }
            }
            if (count == 0) {
                System.out.println("库中没有该商品");
            }
        }
    }

    public static void chuku(WarehouseInformation[] arr) {
        String no;
        String time2 = "";
        int out = 0;
        char c;
        Scanner s2 = new Scanner(System.in);
        int count = 0;
        int flag = 0;
        while (true) {
            System.out.println("***********************************************************");
            System.out.println("           石家庄铁道大学前进22软件开发有限公司");
            System.out.println("                  仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("              请输入商品编号:");
            System.out.println("**********************************************************");
            no = s2.next();
            for (int i = 0; i < 5; i++) {
                if (no.equals(arr[i].getItemno())) {
                    while (true) {
                        System.out.println("***********************************************************");
                        System.out.println("           石家庄铁道大学前进22软件开发有限公司");
                        System.out.println("                  仓库管理系统2022版");
                        System.out.println("***********************************************************");
                        System.out.println("                 1、商品编号:" + arr[i].getItemno());
                        System.out.println("              2、商品名称:" + arr[i].getItemname());
                        System.out.println("          3、供货商信息:" + arr[i].getSuppliername());
                        System.out.println("                4、入库时间:" + arr[i].getWarehousingtime());
                        System.out.println("                 5、存放仓库号:" + arr[i].getWarehousenumber());
                        System.out.println("               6、存放位置信息:" + arr[i].getWarehouseplace());
                        System.out.println("                7、入库商品数量:" + arr[i].getItemnumber());
                        System.out.println("               出库时间:");
                        time2 = s2.next();
                        System.out.println("                   出库数量:");
                        System.out.println("**********************************************************");
                        out = s2.nextInt();
                        if (out < arr[i].getItemnumber()) {
                            System.out.println("           修改信息已完成,是否提交(Y/N)");
                            c = s2.next().charAt(0);
                            if (c == 'Y') {
                                flag = 1;
                                break;
                            }
                        } else {
                            System.out.println("您输入的出库量错误,请重新输入");
                        }
                    }
                    if (flag == 1) {
                        arr[i].setOutnumber(out);
                        arr[i].setShipmenttime(time2);
                        System.out.println("信息保存成功!");
                        break;
                    }
                } else {
                    count++;
                }
            }
            if (count == 5) {
                System.out.println("库中没有该商品");
            }
        }
    }

    public static void chaxun(WarehouseInformation[] arr) {
        System.out.println("***********************************************************");
        System.out.println("           石家庄铁道大学前进22软件开发有限公司");
        System.out.println("                  仓库管理系统2022版");
        System.out.println("***********************************************************");
        System.out.println("1、\t商品编号:" + arr[0].getItemno() + "、商品名称:" + arr[0].getItemname() + "、库存数量:" + (arr[0].getItemnumber() - arr[0].getOutnumber()));
        System.out.println("2、\t商品编号:" + arr[1].getItemno() + "、商品名称:" + arr[1].getItemname() + "、库存数量:" + (arr[1].getItemnumber() - arr[1].getOutnumber()));
        System.out.println("3、\t商品编号:" + arr[2].getItemno() + "、商品名称:" + arr[2].getItemname() + "、库存数量:" + (arr[2].getItemnumber() - arr[2].getOutnumber()));
        System.out.println("4、\t商品编号:" + arr[3].getItemno() + "、商品名称:" + arr[3].getItemname() + "、库存数量:" + (arr[3].getItemnumber() - arr[3].getOutnumber()));
        System.out.println("5、\t商品编号:" + arr[4].getItemno() + "、商品名称:" + arr[4].getItemname() + "、库存数量:" + (arr[4].getItemnumber() - arr[4].getOutnumber()));
        System.out.println("………………………………………………….");
        System.out.println("**********************************************************");
    }
}

在一些重复代码上我们进行了封装,从而节省空间

标签:arr,String,9.16,System,println,public,out
From: https://www.cnblogs.com/zzqq1314/p/17706646.html

相关文章

  • python:安装backgroundremover 0.2.4(Python 3.9.16)
    一,官方代码及文档:https://github.com/nadermx/backgroundremover二,安装backgroundremover的准备工作1,安装pytorch:https://blog.imgtouch.com/index.php/2023/08/03/rocky-linux-an-zhuang-pytorch-pytorch-2-1-python-3-9-16/2, 安装ffmpeg:https://blog.imgtouch.......
  • rocky linux:安装pytorch(pytorch 2.0.1 / Python 3.9.16)
    一,pytorch官网:https://pytorch.org/如图:根据自己的需求选择版本、平台、语言环境等信息,然后运行命令二,运行pip安装命令:[root@imgbin]#pip3installtorchtorchvisiontorchaudio--index-urlhttps://download.pytorch.org/whl/cpuLookinginindexes:https://......
  • 19C-19.16 ORA-17503 ORA-27300 ORA-27301 ORA-27302
    ***alter日志告警2023-07-01T02:05:13.474592+08:00Errorsinfile/u01/app/oracle/diag/rdbms/dg/dg1/trace/dg1_ora_17925.trc:ORA-17503:ksfdopn:2Failedtoopenfile+DATA/dg/PASSWORD/pwddgORA-27300:OSsystemdependentoperation:openfailedwithstatus:13ORA-......
  • 9.16 泛型接口
    对于泛型接口的子类而言,有2种实现方式demo1在子类中继续进行泛型定义interfaceIMessage<T>{publicStringecho(Tt);}classMessageImpl<S>implementsIMessage<S>{publicStringecho(St){return"[echo]"+t;}}publicclassHello......
  • Centos7安装高版本BIND9.16.41(DNS服务器)
    安装高版本BIND9.16.41或9.18.15双数版本为稳定版如9.16、9.18找到BIND官网:https://www.isc.org/download/#BIND1、点击Download:这里以9.16.41版本为例2、打开CentOS系统3、跳转到官方文档,找到EPEL源,复制链接更换源,并安装cd/etc/yum.repos.drm-rf/etc/yum.repos.......
  • Centos 7 安装 Python3.9.16
    1、下载Python官网(https://www.python.org/downloads/)对应的安装包,选择3.9.16的linux版本wgethttps://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz2、解压tgz包tarzxvfPython-3.9.16.tgz-C/opt3、创建Python-3.6.5安装目录mkdir/usr/local/python34、安装依......
  • k8s版本1.18升级至1.19.16
    一、master节点升级#1.yum升级kubernetes插件yuminstallkubeadm-1.19.16-0kubelet-1.19.16-0kubectl-1.19.16-0--disableexcludes=kubernetes#2.升级版本到1.19.16......
  • 单实例Primary快速搭建Standby RAC参考手册(19.16 ADG)
    环境:SingleInstance->RACSingleInstance:db_name=demodb_unique_name=demoinstance_name=demoservice_names=demoRAC(2nodes):db_name=demodb_unique_name=d......
  • 在QEMU-KVM环境下部署Oracle 19.16 RAC
    KVM环境和其他虚拟化或真实生产最大差异主要就是在实施前期准备工作上:具体在DB节点和存储环境的准备工作上有差异,本文会详细说明。而剩余基本软件安装和补丁应用部分......
  • 搭建ogg双向复制时,oracle 19.16向oracle 10.2.0.4 ogg复制时报警OGG-01389、OGG-02246
    文档课题:搭建ogg双向复制时,oracle19.16向oracle10.2.0.4ogg复制时报警OGG-01389、OGG-02246处理记录.源端:IP192.168.133.103数据库oracle11.2.0.464位,实例名:or......