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/\345\210\230\346\261\211\346\226\207/dsd.txt" "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/\345\210\230\346\261\211\346\226\207/dsd.txt" new file mode 100644 index 0000000000000000000000000000000000000000..fa2797e96b835f6175d24650a84d6c6ea86707c9 --- /dev/null +++ "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/\345\210\230\346\261\211\346\226\207/dsd.txt" @@ -0,0 +1,568 @@ +package 练习; + +import java.util.Iterator; +import java.util.Scanner; + +@SuppressWarnings("unused") +public class 草莓果酱1 { + static Scanner xx = new Scanner(System.in); + static String users[][] = new String[100][4]; + static String books[][] = new String[100][5]; + static String pubs[][] = new String[100][3]; + static String loginUser = ""; + + + public static void main(String[] args) { + inner(); + Homepage(); + } + + + private static void inner() { + users[0][0] = "设计部"; + users[0][1] = "武大郎"; + users[0][2] = "2918"; + users[0][3] = "卖饼"; + users[1][0] = "项目部"; + users[1][1] = "西门庆"; + users[1][2] = "321"; + users[1][3] = "隔壁老西"; + + books[0][0] = "老庞"; + books[0][1] = "烧饼如何制作"; + books[0][2] = "352"; + books[0][3] = "梁山出版社"; + books[0][4] = "老baby"; + books[1][0] = "laa"; + books[1][1] = "泡妹秘籍"; + books[1][2] = "10086"; + books[1][3] = "小巷子出版社"; + books[1][4] = "rubber"; + books[2][0] = "彩虹小马"; + books[2][1] = "酸菜鱼"; + books[2][2] = "45252"; + books[2][3] = "烧饼出版社"; + books[2][4] = "乌鸡哥"; + books[3][0] = "a45211"; + books[3][1] = "飞机头"; + books[3][2] = "2054214"; + books[3][3] = "波摆设出版社"; + books[3][4] = "代理商k"; + + pubs[0][0] = “雕塑出版社"; + pubs[0][1] = "北京"; + pubs[0][2] = "大象"; + pubs[1][0] = "小出版社"; + pubs[1][1] = "说的是看到"; + pubs[1][2] = "山东省"; + pubs[2][0] = "大雕塑出版社"; + pubs[2][1] = "博白"; + pubs[2][2] = "dsd"; + } + + + private static void Homepage() { + System.out.println("*****欢迎来到的图书馆*****"); + while (true) { + System.out.println("请选择输入:1.注册 2.登录"); + int key = xx.nextInt(); + switch (key) { + case 1: + writer(); + break; + case 2: + login(); + break; + default: + System.out.println("系统退出!"); + System.exit(0); + break; + } + } + } + + private static void login() { + System.out.println("欢迎来到登录界面~"); + System.out.println("请输入用户名:"); + String username = xx.next(); + System.out.println("请输入一个密码:"); + String password = xx.next(); + boolean flat = false; + for (int i = 0; i < users.length; i++) { + if (username.equals(users[i][1]) && password.equals(users[i][2])) { + flat = true; + loginUser = username; + break; + } + } + if (flat) { + System.out.println(loginUser + ",恭喜你登陆成功!"); + System.out.println("*****登录界面结束*****"); + librarygl(); + } else { + System.out.println("该用户不存在或者密码错误!请重新登录!"); + } + } + + + private static void writer() { + System.out.println("欢迎来到注册界面~"); + int wrindex = -1; + for (int i = 0; i < users.length; i++) { + if (users[i][0] == null) { + wrindex = i; + break; + } + } + System.out.println("请输入部门:"); + users[wrindex][0] = xx.next(); + System.out.println("请输入用户名:"); + users[wrindex][1] = xx.next(); + System.out.println("请输入密码:"); + users[wrindex][2] = xx.next(); + users[wrindex][3] = "烧饼会员"; + System.out.println("注册成功!"); + System.out.println("*****注册界面结束*****"); + Homepage(); + } + + + private static void librarygl() { + System.out.println("请输入数字进行选择:1.图书管理 2.出版社管理 3.退出登录 4.退出系统"); + int order = xx.nextInt(); + switch (order) { + case 1: + + gl(); + break; + case 2: + + pubgl(); + break; + case 3: + + loginUser = " "; + System.out.println("退出登录成功!"); + Homepage(); + break; + case 4: + + System.out.println("退出系统成功"); + System.exit(0); + break; + default: + Homepage(); + break; + } + } + + + private static void gl() { + System.out.println("******欢迎来到图书馆管理菜单******"); + System.out.println("请选择输入管理项目:1.增加 2.删除 3.更新 4.查询"); + int glxz = xx.nextInt(); + switch (glxz) { + case 1: + gladd(); + break; + case 2: + gldelect(); + break; + case 3: + glnew(); + break; + case 4: + gllookfor(); + break; + default: + librarygl(); + break; + } + } + + + private static void pubgl() { + + int pubxz = xx.nextInt(); + switch (pubxz) { + case 1: + pubadd(); + break; + case 2: + pubdelect(); + break; + case 3: + pubnew(); + break; + case 4: + pubname(); + break; + case 5: + puball(); + break; + case 6: + + librarygl(); + break; + default: + librarygl(); + break; + } + } + + private static void puball() { + System.out.println("出版社名称\t\t地址\t\t联系人"); + for (int i = 0; i < pubs[i].length; i++) { + for (int j = 0; j < pubs[j].length; j++) { + if (pubs[i][0] != null) { + System.out.print(pubs[i][j] + "\t\t"); + } + } + System.out.println(); + + } + pubgl(); + } + + + private static void pubname() { + System.out.println("请输入出版社名称:"); + String pubname = xx.next(); + System.out.println("出版社名称\t地址\t联系人"); + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0] != null && pubs[i][1].indexOf(pubname) != -1) { + System.out.println(pubs[i][0] + "\t" + pubs[i][1] + "\t" + pubs[i][2]); + break; + } + System.out.println("出版社名称错误,出版社信息不存在"); + break; + + } + System.out.println(); + pubgl(); + } + + + private static void pubnew() { + int pubc = -1; + boolean pubcc = false; + System.out.println("请输入出版社名称:"); + String pubccc = xx.next(); + for (int i = 0; i < books.length; i++) { + if (pubccc.equals(books[i][0])) { + pubc = i; + pubcc = true; + break; + } + System.out.println("输入错误,更新失败"); + break; + } + if (pubcc) { + books[pubc][0] = pubccc; + System.out.println("请输入出版社名称"); + books[pubc][1] = xx.next(); + System.out.println("请输入地址:"); + books[pubc][2] = xx.next(); + System.out.println("请输入联系人:"); + books[pubc][3] = xx.next(); + System.out.println("出版社信息更新成功!"); + } + pubgl(); + } + + + private static void pubdelect() { + int pubb = -1; + boolean pubbb = false; + System.out.println("请输入出版社名称:"); + String pubbbb = xx.next(); + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0].equals(pubbbb)) { + pubbb = true; + pubb = i; + break; + } + System.out.println("删除失败"); + break; + } + for (int j = 0; j < pubs.length; j++) { + if (pubbb) { + books[pubb][j] = null; + System.out.println("删除成功"); + break; + } + pubgl(); + } + + } + + private static void pubadd() { + int puba = -1; + boolean pubaa = false; + System.out.println("请输入出版社名称:"); + String pubaaa = xx.next(); + for (int i = 0; i < pubs.length; i++) { + if (pubaaa.equals(pubs[i][0])) { + System.out.println("出版社已存在"); + break; + } else { + pubaa = true; + puba = i; + break; + } + } + if (pubaa) { + books[puba][0] = pubaaa; + System.out.println("请输入出版社名称:"); + books[puba][1] = xx.next(); + System.out.println("请输入地址:"); + books[puba][2] = xx.next(); + System.out.println("请输入联系人:"); + books[puba][3] = xx.next(); + System.out.println("新增出版社信息成功!"); + } + pubgl(); + } + + + private static void gladd() { + int glh = -1; + boolean a = false; + System.out.println("请输入书籍编号:"); + String hao = xx.next(); + for (int i = 0; i < books.length; i++) { + if (hao.equals(books[i][0])) { + System.out.println("图书已存在"); + break; + } else { + a = true; + glh = i; + break; + } + } + if (a) { + books[glh][0] = hao; + System.out.println("请输入书名:"); + books[glh][1] = xx.next(); + System.out.println("请输入价格:"); + books[glh][2] = xx.next(); + System.out.println("请输入出版社:"); + books[glh][3] = xx.next(); + System.out.println("请输入作者:"); + books[glh][4] = xx.next(); + System.out.println("新增书籍信息成功!"); + } + gl(); + } + + + private static void gldelect() { + int de = -1; + boolean b = false; + System.out.println("请输入书籍编码:"); + String hao1 = xx.next(); + for (int i = 0; i < books.length; i++) { + if (books[i][0].equals(hao1)) { + b = true; + de = i; + break; + } + System.out.println("删除失败"); + break; + } + for (int j = 0; j < books.length; j++) { + if (b) { + books[de][j] = null; + System.out.println("删除成功"); + break; + } + gl(); + } + } + + + private static void glnew() { + int ne = -1; + boolean c = false; + System.out.println("请输入书籍编号:"); + String hao2 = xx.next(); + for (int i = 0; i < books.length; i++) { + if (hao2.equals(books[i][0])) { + ne = i; + c = true; + break; + } + System.out.println("输入错误,更新失败"); + break; + } + if (c) { + books[ne][0] = hao2; + System.out.println("请输入书名"); + books[ne][1] = xx.next(); + System.out.println("请输入价格:"); + books[ne][2] = xx.next(); + System.out.println("请输入出版社:"); + books[ne][3] = xx.next(); + System.out.println("请输入作者:"); + books[ne][4] = xx.next(); + System.out.println("书籍信息更新成功!"); + } + gl(); + } + + private static void gllookfor() { + System.out.println("请选择输入查询方式:1.ISBN查询 2.书名查询(模糊)3.出版社查询 4.作者查询 5.价格范围查询 6.所有书籍信息 7.返回上一级菜单"); + int lk = xx.nextInt(); + switch (lk) { + case 1: + System.out.println("请输入ISBN:"); + String bkisbn = xx.next(); + lkisbn(bkisbn); + break; + case 2: + System.out.println("请输入书名关键字:"); + String bkname = xx.next(); + lkname(bkname); + break; + case 3: + System.out.println("请输入出版社:"); + String bkpub = xx.next(); + lkpub(bkpub); + break; + case 4: + System.out.println("请输入作者:"); + String bkwriter = xx.next(); + lkwriter(bkwriter); + break; + case 5: + System.out.println("请输入价格范围:"); + System.out.println("最高价:"); + Double bkpricemax = xx.nextDouble(); + System.out.println("最低价:"); + Double bkpricemin = xx.nextDouble(); + lkprice(bkpricemax, bkpricemin); + break; + case 6: + lkallbooks(); + break; + case 7: + + System.out.println("返回成功"); + gl(); + break; + + default: + System.out.println("识别错误"); + break; + } + } + + + private static void lkisbn(String isbn) { + for (int i = 0; i < books.length; i++) { + if (isbn.equals(books[i][0])) { + System.out.println("ISBN\t书名\t价格\t出版社\t作者"); + System.out.println(books[i][0] + "\t" + books[i][1] + "\t" + books[i][2] + "\t" + books[i][3] + "\t" + + books[i][4]); + break; + } + System.out.println("编码错误,书籍信息不存在"); + break; + } + System.out.println(); + gllookfor(); + + } + + + private static void lkname(String name) { + System.out.println("ISBN\t书名\t价格\t出版社\t作者"); + for (int i = 0; i < books.length; i++) { + if (books[i][0] != null && books[i][1].indexOf(name) != -1) { + System.out.println(books[i][0] + "\t" + books[i][1] + "\t" + books[i][2] + "\t" + books[i][3] + "\t" + + books[i][4]); + break; + } + System.out.println("书名关键字错误,书籍信息不存在"); + break; + + } + System.out.println(); + gllookfor(); + } + + + private static void lkpub(String pub) { + int c = -1; + boolean cc = false; + for (int i = 0; i < books.length; i++) { + if (books[i][0] != null && books[i][3].equals(pub)) { + cc = true; + c = i; + } + } + if (cc) { + System.out.println("ISBN\t书名\t价格\t出版社\t作者"); + System.out.println( + books[c][0] + "\t" + books[c][1] + "\t" + books[c][2] + "\t" + books[c][3] + "\t" + books[c][4]); + } else { + System.out.println("出版社错误,书籍信息不存在"); + } + gllookfor(); + } + + + private static void lkwriter(String wr) { + boolean d = false; + int d1 = -1; + for (int i = 0; i < books.length; i++) { + if (books[i][0] != null && books[i][4].equals(wr)) { + d1 = i; + d = true; + } + + } + for (int i = 0; i < books.length; i++) { + if (d) { + System.out.println("ISBN\t书名\t价格\t出版社\t作者"); + System.out.print(books[d1][0] + "\t" + books[d1][1] + "\t" + (books[d1][2] + "") + "\t" + books[d1][3] + + "\t" + books[d1][4]); + System.out.println(); + } else { + System.out.println("作者错误,书籍信息不存在"); + break; + } + } + gllookfor(); + } + + + private static void lkprice(Double prx, Double prn) { + System.out.println("ISBN\t书名\t价格\t出版社\t作者"); + for (int i = 0; i < books.length - i; i++) { + if (books[i][0] != null + && (prx >= Double.parseDouble(books[i][2]) && Double.parseDouble(books[i][2]) >= prn)) { + System.out.print(books[i][0] + "\t" + books[i][1] + "\t" + (books[i][2] + "") + "\t" + books[i][3] + + "\t" + books[i][4]); + } + System.out.println(); + } + System.out.println("没有找到书籍信息"); + gllookfor(); + } + + + private static void lkallbooks() { + System.out.println("ISBN\t\t书名\t\t价格\t\t出版社\t\t作者"); + for (int i = 0; i < books[i].length; i++) { + for (int j = 0; j < books[j].length; j++) { + if (books[i][0] != null) { + System.out.print(books[i][j] + "\t\t"); + } + } + System.out.println(); + + } + gllookfor(); + } +} \ No newline at end of file