From f124d018bf7ea952fa5fa3c116815cb696080c7b Mon Sep 17 00:00:00 2001 From: liang-qixin <1051907145@qq.com> Date: Sun, 25 Apr 2021 20:00:26 +0800 Subject: [PATCH] yang --- .../Wqe.java" | 77 +++++++++++++------ 1 file changed, 54 insertions(+), 23 deletions(-) diff --git "a/\351\241\271\347\233\256\344\275\234\344\270\232\357\274\210\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/\346\242\201\345\220\257\351\221\253/Wqe.java" "b/\351\241\271\347\233\256\344\275\234\344\270\232\357\274\210\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/\346\242\201\345\220\257\351\221\253/Wqe.java" index b4f8db4..ce47259 100644 --- "a/\351\241\271\347\233\256\344\275\234\344\270\232\357\274\210\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/\346\242\201\345\220\257\351\221\253/Wqe.java" +++ "b/\351\241\271\347\233\256\344\275\234\344\270\232\357\274\210\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/\346\242\201\345\220\257\351\221\253/Wqe.java" @@ -58,9 +58,8 @@ public class Wqe { denglu(); break; - } - //注册 - if (q == 2) { + }//注册 + else if (q == 2) { zhuce(); System.out.println("注册成功,将自动跳转登录页面"); denglu(); @@ -68,6 +67,7 @@ public class Wqe { } else { System.out.println("输入错误请重新输入!!!"); } + } //系统界面,判断登录输入是否正确(判断在dnglu();完成) @@ -90,7 +90,7 @@ public class Wqe { boolean flag = isExistUserName(userName); //判断用户 - if (flag) { + if (!flag) { System.out.println("该用户名可用,已注册成功"); int index = getFirstNullUserIndex(); a[index][1] = userName; @@ -154,12 +154,12 @@ public class Wqe { if (falg == true) { break; } else { - System.out.println("用户不存在,请重新输入!!"); + System.out.println("输入错误,请重新输入!!"); } } } - /* 登录成功,进入系统 */private static void shouye() { + /* 登录成功,进入主系统 */private static void shouye() { System.out.println("***************系统菜单***************\r\n" + "\t1. 图书管理\r\n" + "\t2. 出版社管理\r\n" + "\t3. 退出登录\r\n" + "\t4. 退出系统\r\n"); @@ -180,6 +180,7 @@ public class Wqe { break; case 4: //退出系统 + System.out.println("退出成功"); System.exit(0); break; default: @@ -407,10 +408,15 @@ public class Wqe { break; case 6: for (int i = 0; i < b.length; i++) { - System.out.println(); - for (int j = 0; j < b[i].length; j++) { - System.out.print(b[i][j]+"\t"); + if (b[i][0]!=null) { + System.out.println(); + for (int j = 0; j < b[i].length; j++) { + if (b[i][j]!=null) { + System.out.print(b[i][j]+"\t"); + } + } } + } System.out.println(""); System.out.println("按t返回"); @@ -468,15 +474,8 @@ public class Wqe { pressSystem(); break; case 3: - System.out.println("请输入要更新的出版社名:"); - String renew = liang.next(); - int index01=-1; - for (int i = 0; i < b.length; i++) { - if (renew.equals(b[i][0])) { - index01=i; - break; - } - } + int index01=while01(index); + for (int i1 = 0; i1 < b.length; i1++) { if (i1==0) { System.out.println("请输入更改后图书的图书名称:"); @@ -485,13 +484,13 @@ public class Wqe { } if (i1==1) { System.out.println("请输入更改后图书的图书价格:"); - String change=liang.next(); - c[index01][i1]=change; + String change1=liang.next(); + c[index01][i1]=change1; } if (i1==2) { System.out.println("请输入更改后图书的图书所属出版社:"); - String change=liang.next(); - b[index01][i1]=change; + String change2=liang.next(); + b[index01][i1]=change2; } } @@ -518,7 +517,9 @@ public class Wqe { break; case 5: for (int i = 0; i < c.length; i++) { - System.out.println(c[i][0]); + if (c[i][0]!=null) { + System.out.println(c[i][0]); + } } System.out.println(); @@ -535,6 +536,24 @@ public class Wqe { } + /*出版社名循环输入*/private static int while01(int index) { + System.out.println("请输入要更新的出版社名:"); + String renew = liang.next(); + int index01=-1; + boolean flag=ifYesORNo(renew,index); + for (int i = 0; i < index+1; i++) { + if (flag) { + index01=i; + System.out.println(index01); + break; + }else if(c[index][0]==null){ + System.out.println("输入的出版社不存在,请重新输入"); + while01(index); + } + } + return index01; + } + /* 判断输入出版社是否可删除 */private static void delect() { System.out.println("请输入要删除的出版社"); @@ -558,6 +577,18 @@ public class Wqe { } } + /*判断输入出版社是否存在*/private static boolean ifYesORNo(String renew,int index) { + boolean flag= true; + for (int i = 0; i < index; i++) { + if (renew.equals(c[i][0])) { + flag=true; + }else { + flag=false; + } + } + return flag; + + } /* c 找出出版社表第一个null值 */private static int CfirstNullIndex() { int index = -1; -- Gitee