首页 > 其他分享 >9.17 四次分解

9.17 四次分解

时间:2023-09-17 19:56:05浏览次数:37  
标签:scanner String 9.17 System 四次 分解 warehouseInformation println out

 

Import java.util.Scanner;

 

Public class WarehouseManagement {

Static int numOfItems = 0;

Static WarehouseInformation[] warehouseInformations = new WarehouseInformation[5];

 

Public static void main(String[] args) {

        initializeData();

 

        Scanner scanner = new Scanner(System.in);

        While (true) {

            printMainMenu();

            System.out.println(“请输入数字选择功能:”);

            Int option = scanner.nextInt();

            Switch (option) {

                Case 1:

                    addCommodity(scanner);

                    break;

                case 2:

                    modifyWarehouse(scanner);

                    break;

                case 3:

                    outboundWarehouse(scanner);

                    break;

                case 4:

                    countGoods();

                    break;

                default:

                    System.out.println(“该选项不存在”);

            }

        }

}

 

Private static void initializeData() {

        warehouseInformations[0] = new WarehouseInformation(“20224085”, “华为笔记本电脑”, “河北省正大光明有限公司”, “003”, “0180350”, 100, 0);

        warehouseInformations[1] = new WarehouseInformation(“20224086”, “Apple iPhone”, “Guangdong Xinrui Technology Co., Ltd.”, “004”, “0180351”, 50, 10);

        warehouseInformations[2] = new WarehouseInformation(“20224087”, “Samsung Tablet”, “Shanghai Letian Electronics Co., Ltd.”, “005”, “0180352”, 80, 20);

        warehouseInformations[3] = new WarehouseInformation(“20224088”, “Huawei Smartphone”, “Beijing Zhongxing Technology Co., Ltd.”, “006”, “0180353”, 120, 50);

        warehouseInformations[4] = new WarehouseInformation(“20224089”, “Xiaomi TV”, “Zhejiang Rongyao Electronics Co., Ltd.”, “007”, “0180354”, 60, 30);

        numOfItems = 5;

}

 

Private static void printMainMenu() {

        System.out.println(“***********************************************************”);

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

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

        System.out.println(“                  1、商品入库管理”);

        System.out.println(“                  2、商品信息修改”);

        System.out.println(“                  3、商品出库管理”);

        System.out.println(“                  4、仓库盘点管理”);

        System.out.println(“***********************************************************”);

}

 

Private static void addCommodity(Scanner scanner) {

        printItemPrompt(“商品编码”);

        String itemno = scanner.next();

        printItemPrompt(“商品名称”);

        String itemname = scanner.next();

        printItemPrompt(“供货商信息”);

        String suppliername = scanner.next();

        printItemPrompt(“入库时间”);

        String warehousingtime = scanner.next();

        printItemPrompt(“存放仓库号”);

        String warehousenumber = scanner.next();

        printItemPrompt(“存放位置信息”);

        String warehouseplace = scanner.next();

        printItemPrompt(“入库商品数量”);

        int itemnumber = scanner.nextInt();

 

        printItemInfo(itemno, itemname, suppliername, warehousingtime, warehousenumber, warehouseplace, itemnumber);

 

        System.out.println(“该商品入库操作已完成,是否提交(Y/N):”);

        String confirm = scanner.next();

        If (confirm.equalsIgnoreCase(“Y”)) {

            warehouseInformations[numOfItems] = new WarehouseInformation(itemno, itemname, suppliername, warehousenumber, warehouseplace, itemnumber, 0);

            numOfItems++;

            System.out.println(“提交成功!”);

        }

}

 

Private static void modifyWarehouse(Scanner scanner) {

        printItemPrompt(“商品编号”);

        String itemno = scanner.next();

        WarehouseInformation warehouseInformation = findItemByNo(itemno);

        If (warehouseInformation == null) {

            System.out.println(“库中没有该商品”);

            Return;

        }

 

        printItemInfo(warehouseInformation);

 

        System.out.println(“请输入需要修改的信息编号(1-7):”);

        Int fieldNum = scanner.nextInt();

        Scanner.nextLine();  // 读取换行符

 

        String[] fieldNames = { “商品编号”, “商品名称”, “供货商信息”, “入库时间”, “存放仓库号”, “存放位置信息”, “入库商品数量” };

        String fieldName = fieldNames[fieldNum – 1];

 

        System.out.println(“请输入修改后的” + fieldName + “:”);

        String newVal = scanner.nextLine();

 

        printItemPrompt(“是否保存(Y/N):”);

        String confirm = scanner.next();

        If (confirm.equalsIgnoreCase(“Y”)) {

            modifyData(warehouseInformation, fieldNum, newVal);

            System.out.println(“保存成功!”);

        }

}

 

Private static void outboundWarehouse(Scanner scanner) {

        printItemPrompt(“商品编号”);

        String itemno = scanner.next();

        WarehouseInformation warehouseInformation = findItemByNo(itemno);

        If (warehouseInformation == null) {

            System.out.println(“库中没有该商品”);

            Return;

        }

 

        printItemInfo(warehouseInformation);

 

        int stockQuantity = warehouseInformation.getItemnumber() – warehouseInformation.getOutnumber();

        System.out.println(“全部库存数量:” + stockQuantity);

 

        System.out.println(“请输入出库数量:”);

        Int outboundQuantity = scanner.nextInt();

        If (outboundQuantity > stockQuantity) {

            System.out.println(“超过库存数量!”);

            Return;

        }

 

        printItemPrompt(“是否保存出库信息(Y/N):”);

        String confirm = scanner.next();

        If (confirm.equalsIgnoreCase(“Y”)) {

            modifyData(warehouseInformation, 8, String.valueOf(outboundQuantity));

            System.out.println(“保存成功!”);

        }

}

 

Private static void countGoods() {

        For (int I = 0; I < numOfItems; i++) {

            System.out.println(“商品编号:” + warehouseInformations[i].getItemno());

            System.out.println(“商品名称:” + warehouseInformations[i].getItemname());

            System.out.println(“库存数量:” + (warehouseInformations[i].getItemnumber() – warehouseInformations[i].getOutnumber()));

            System.out.println(“………………………………………………….”);

        }

}

 

Private static void modifyData(WarehouseInformation warehouseInformation, int fieldNum, String newVal) {

        Switch (fieldNum) {

            Case 1:

                warehouseInformation.setItemno(newVal);

                break;

            case 2:

                warehouseInformation.setItemname(newVal);

                break;

            case 3:

                warehouseInformation.setSuppliername(newVal);

                break;

            case 4:

                warehouseInformation.setWarehousingtime(newVal);

                break;

            case 5:

                warehouseInformation.setWarehousenumber(newVal);

                break;

            case 6:

                warehouseInformation.setWarehouseplace(newVal);

                break;

            case 7:

                warehouseInformation.setItemnumber(Integer.parseInt(newVal));

                break;

            case 8:

                warehouseInformation.setOutnumber(Integer.parseInt(newVal));

                break;

            default:

                System.out.println(“该选项不存在!”);

        }

}

 

Private static WarehouseInformation findItemByNo(String itemno) {

        For (int I = 0; I < numOfItems; i++) {

            If (warehouseInformations[i].getItemno().equals(itemno)) {

                Return warehouseInformations[i];

            }

        }

        Return null;

}

 

Private static void printItemPrompt(String fieldName) {

        System.out.println(“请输入” + fieldName + “:”);

}

 

Private static void printItemInfo(WarehouseInformation warehouseInformation) {

        System.out.println(“1.商品编号:” + warehouseInformation.getItemno());

        System.out.println(“2.商品名称:” + warehouseInformation.getItemname());

        System.out.println(“3.供货商信息:” + warehouseInformation.getSuppliername());

        System.out.println(“4.入库时间:” + warehouseInformation.getWarehousingtime());

        System.out.println(“5.存放仓库号:” + warehouseInformation.getWarehousenumber());

        System.out.println(“6.存放位置信息:” + warehouseInformation.getWarehouseplace());

        System.out.println(“7.入库商品数量:” + warehouseInformation.getItemnumber());

        System.out.println(“**********************************************************”);

}

 

Private static void printItemInfo(String itemno, String itemname, String suppliername, String warehousingtime, String warehousenumber, String warehouseplace, int itemnumber) {

        System.out.println(“1.商品编号:” + itemno);

        System.out.println(“2.商品名称:” + itemname);

        System.out.println(“3.供货商信息:” + suppliername);

        System.out.println(“4.入库时间:” + warehousingtime);

        System.out.println(“5.存放仓库号:” + warehousenumber);

        System.out.println(“6.存放位置信息:” + warehouseplace);

        System.out.println(“7.入库商品数量:” + itemnumber);

        System.out.println(“**********************************************************”);

}

}

 

标签:scanner,String,9.17,System,四次,分解,warehouseInformation,println,out
From: https://www.cnblogs.com/zeyangshuaige/p/17709629.html

相关文章

  • 每日总结|9.17-别为打翻的牛奶哭泣,今天你能拥有更美味的果汁
    超级喜欢两首歌:越来越不懂-蔡健雅你不明白-Joysaaaa今天没干什么其实,都是一些不太费脑子的。休息了,恢复精力,下周才能元气满满啊!1、王老师的需求文档作业,做了一部分,查一些资料2、看学习视频3、人月神话,今天看了不到两章(我本来还说要每天看一点呢,结果还是比较忙的)4、c#(......
  • 开学测试修改(9.17)
    packagehomework;publicclassWarehouseInformation{privateStringitemno;privateStringitemname;privateStringsuppliername;privateStringwarehousingtime;privateStringshipmenttime;privateStringwarehousenumber;privateStr......
  • 9.17
    packagetest;publicclassWarehouseInformation{privateStringitemno;//编号,八位数字privateStringitemname;//名称privateStringsuppliername;//供货商privateStringwarehousingtime;//入库时间,八位数字privateStringshipmenttime;//出库时间,......
  • 开学测试题分解步骤
    importjava.util.Scanner;//数据类WarehouseInformationclassWarehouseInformation{   privateStringproductId;   privateStringproductName;   privateStringsupplier;   privateStringentryDate;   privateintwarehouseNumber; ......
  • 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的芯片要用多少片......
  • 基于奇异值分解的点云配准RT计算原理
    参考文献SorkineO.Least-squaresrigidmotionusingsvd.2009.知乎|三维点云匹配,ICP算法详解百度百科|正交矩阵百度百科|奇异值分解这里这样推导好像不严谨。↩︎未经作者授权,禁止转载THEEND......
  • 四次挥手
    第一次挥手(ActiveClose):客户端发送一个FIN(Finish)报文给服务器,表示客户端不再发送数据。客户端进入FIN_WAIT_1状态,等待服务器的确认。第二次挥手(PassiveClose):服务器收到客户端的FIN报文后,发送一个ACK(Acknowledge)报文作为确认,表示已经收到了客户端的关闭请求。服务器进入CLOSE_......
  • 奇异值分解,逆,左逆,右逆与伪逆
    奇异值分解(SingularValueDecomposition,SVD)可以被看做是方阵特征值分解的推广,适用于任意形状的矩阵。对于矩阵$A\in\R^{m\timesn}$,不失一般性,假设$m\geqn$,奇异值分解期望实现:$A=U\SigmaV^T$其中$U,V$分别为$m,n$阶正交矩阵,其中向量称为左/右奇异向量,$\Sigma......
  • OpenHarmony南向开发培训第四次作业(D9案例数据上云)
    首先,要实现Bearpi(Hi3861)的数据上云,我们要先了解bearpi的上云案例是怎么运行的这里我选取的是D9_iot_cloud_oc_manhole_cover这个案例那么既然是上云,我们肯定要先链接平台,而在案例里链接平台的函数是staticintCloudMainTaskEntry(void)你就记住你什都不用改,要改什么会在文章最后......