diff --git "a/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.bat" "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.bat" new file mode 100644 index 0000000000000000000000000000000000000000..cc07219760c366986514b4065fa7dfdd2fa1902b --- /dev/null +++ "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.bat" @@ -0,0 +1 @@ +java Dome04 \ No newline at end of file diff --git "a/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.class" "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.class" new file mode 100644 index 0000000000000000000000000000000000000000..06965deeaaebca8b1cac2b99a92e6a3279935442 --- /dev/null +++ "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.class" @@ -0,0 +1,581 @@ +package com.md.lession; + +import java.util.Scanner; + +public class Dome04 { + //用户信息(部门、用户名、密码、用户角色) + static String uesr[][] = new String [100][4]; + //书籍信息(编码(ISBN)、书籍名称、价格、出版社、作者) + static String books[][] = new String [100][5]; + //出版社信息(出版社名称、地址、联系人) + static String pubs [][]=new String [100][3]; + //信息扫描 + static Scanner scan = new Scanner(System.in); + static String dengluUsers = ""; + public static void main(String[] args) { + xinxiluru(); + TSGL(); + + } + private static void TSGL() { + while (true) { + System.out.println("欢迎来到闽大图书管理系统!"); + System.out.println("1.登录 2.注册"); + int key = scan.nextInt(); + + switch (key) { + case 1://登录 + yonghudenglu(); + break; + case 2://注册 + yonghuzhuche(); + break; + default: + break; + } + break; + } + } + private static void yonghudenglu() { + //登录 + System.out.println("请输入用户名:"); + String dlName = scan.next(); + System.out.println("请输入密码:"); + String dlPassword = scan.next(); + + boolean flag = false; + for (int i = 0; i < uesr.length; i++) { + if (dlName.equals(uesr[i][1]) && dlPassword.equals(uesr[i][2])) { + flag = true; + break; + } + } + if (flag) { + System.out.println("登录成功!"); + dengluUsers=dlName; + shujiguanli(); + }else { + System.out.println("该用户不存在或者密码错误!请重新登录!"); + yonghudenglu(); + } + } + private static void shujiguanli() { + System.out.println(dengluUsers+",欢迎使用闽大书籍管理系统"); + System.out.println("请输入数字进行选择:1.图书管理 2.出版社管理 3.退出登录 4.退出系统"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //图书管理 + bookgl(); + break; + case 2: + //出版社管理 + chubansgl(); + break; + case 3: + //退出登录 + System.out.println("已退出登录!"); + TSGL(); + break; + case 4: + //退出系统 + System.out.println("已退出系统!"); + break; + default: + break; + } + } + private static void bookgl() { + System.out.println("请输入:1.增加 2.删除 3.更新 4.查询 5.返回上一级菜单"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //增加 + zhengjia(); + break; + case 2: + //删除 + shanchu(); + break; + case 3: + //更新 + gengxin(); + break; + case 4: + //查询 + chaxun(); + break; + case 5: + //返回上一级菜单 + shujiguanli(); + break; + default: + break; + } + } + private static void zhengjia() {//增加 + System.out.println("请输入图书ISBN:"); + String bianhao = scan.next(); + System.out.println("请输入书名:"); + String shuming = scan.next(); + System.out.println("请输入价格:"); + String jiage = scan.next(); + System.out.println("请输入出版社:"); + String chubanshe = scan.next(); + System.out.println("请输入作者:"); + String zuozhe = scan.next(); + + //找重 + boolean flag=false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + flag=true; + break; + } + } + if (flag) { + System.out.println("图书已存在,请重新输入!"); + bookgl(); + }else { + //找空值(null) + int in=-1; + for (int i = 0; i < books.length; i++) { + if (books[i][0]==null) { + in=i; + break; + } + } + //赋值 + books[in][0]=bianhao; + books[in][1]=shuming; + books[in][2]=jiage; + books[in][3]=chubanshe; + books[in][4]=zuozhe; + System.out.println("添加成功!"); + bookgl(); + } + + } + private static void shanchu() {//删除 + System.out.println("请输入要删除的书本名称:"); + String shan = scan.next(); + //找重 + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shan.equals(books[i][0])) { + books[i][0] = null; + books[i][1] = null; + books[i][2] = null; + books[i][3] = null; + books[i][4] = null; + System.out.println("删除成功!"); + flag = true; + break; + } + } + if (flag) { + bookgl(); + }else { + System.out.println("没有找到该书!\\r\\n\"+\"删除失败!"); + bookgl(); + } + } + private static void gengxin() {//更新 + System.out.println("请输入ISBN号:"); + String bianhao = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + books[i][1] = null; + books[i][2] = null; + books[i][3] = null; + books[i][4] = null; + + System.out.println("请输入新的书名:"); + books[i][1] = scan.next(); + System.out.println("请输入新的价格:"); + books[i][2] = scan.next(); + System.out.println("请输入新的出版社:"); + books[i][3] = scan.next(); + System.out.println("请输入新的作者:"); + books[i][4] = scan.next(); + System.out.println("更新成功!"); + flag = true; + break; + } + } + + if (flag) { + bookgl(); + }else { + System.out.println("该ISBN号不存在!!!"); + bookgl(); + } + + } + private static void chaxun() {//查询 + System.out.println("1.isbn 2.书名(模糊) 3.出版社 4. 作者 5. 价格范围 6.查询所有 7.返回上一级"); + int key = scan.nextInt(); + + switch (key) { + case 1://isbn + isbncx(); + break; + case 2://书名(模糊) + shumingcx(); + break; + case 3://出版社 + chubanscx(); + break; + case 4:// 作者 + zuozhecx(); + break; + case 5:// 价格范围 + jiagecx(); + break; + case 6://查询所有 + suoyoucx(); + break; + case 7://返回上一级 + bookgl(); + break; + default: + break; + } + + } + private static void isbncx() {//isbn + System.out.println("请输入ISBN号:"); + String bianhao = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("该ISBN号不存在!!!"); + chaxun(); + } + } + private static void shumingcx() {//书名(模糊) + System.out.println("请输入要查询的书名:"); + String shuming = scan.next(); + System.out.println("ISBN \t" + "书名 \t\t" + "价格 \t" + "出版社 \t" + "作者 \t\t"); + for (int i = 0; i < books.length; i++) { + if (books[i][1] != null && books[i][1].indexOf(shuming) != -1) { + System.out.println(books[i][0] + "\t" + books[i][1] + "\t" + books[i][2] + "\t" + books[i][3] + "\t" + + books[i][4] + "\t"); + } + } + chaxun(); + } + private static void chubanscx() {//出版社 + System.out.println("请输入出版社名称:"); + String shuming = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shuming.equals(books[i][3])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("该出版社不存在!!!"); + chaxun(); + } + } + + private static void zuozhecx() {// 作者 + System.out.println("请输入作者名字:"); + String shuming = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shuming.equals(books[i][4])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("没有该作者!!!"); + chaxun(); + } + } + private static void jiagecx() {// 价格范围 + System.out.println("请输入最小价格:"); + double xiao = scan.nextDouble(); + System.out.println("请输入最大价格:"); + double da = scan.nextDouble(); + + boolean flag = false; + + for (int i = 0; i < books.length; i++) { + if (books[i][0]!=null) { + double price = Double.parseDouble(books[i][2]); + if (price >= xiao && price <= da) { + for (int j = 0; j < books[i].length; j++) { + System.out.println(books[i][j]+"\t"); + flag=true; + } + }else { + System.out.println("没有书在这个价格之间!"); + } + } + } + chaxun(); + } + private static void suoyoucx() {//查询所有 + System.out.print("ISBN \t "+"书名 \t"+"价格 \t"+"出版社 \t"+"作者 \t"); + System.out.println(); + for (int i = 0; i < books.length; i++) { + if (books[i][0]!=null) { + System.out.print(books[i][0]+"\t"); + System.out.print(books[i][1]+"\t"); + System.out.print(books[i][2]+"\t"); + System.out.print(books[i][3]+"\t"); + System.out.print(books[i][4]+"\t"); + System.out.println(); + } + } + chaxun(); + } + + + + private static void chubansgl() { + System.out.println("请输入:1.增加 2.删除 3.更新 4.根据出版社名称查询 5.查询所有出版社 6.返回上一级菜单"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //增加 + zhengjia2(); + break; + case 2: + //删除 + shanchu2(); + break; + case 3: + //更新 + gengxin2(); + break; + case 4: + chubanshemccx(); + //根据出版社名称查询 + break; + case 5: + cbssuoyoucx(); + //查询所有出版社 + break; + case 6: + //返回上一级菜单 + shujiguanli(); + break; + default: + break; + } + } + private static void zhengjia2() {//增加 + System.out.println("请输入出版社名称:"); + String cbsName = scan.next(); + System.out.println("请输入出版社地址:"); + String cbsAdd = scan.next(); + System.out.println("请输入出版社联系人:"); + String cbsPhone = scan.next(); + + //找重 + boolean flag=false; + for (int i = 0; i < pubs.length; i++) { + if (cbsName.equals(pubs[i][0])) { + flag=true; + break; + } + } + if (flag) { + System.out.println("出版社已存在,请重新输入!"); + chubansgl(); + }else { + //找空值(null) + int in=-1; + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0]==null) { + in=i; + break; + } + } + //赋值 + pubs[in][0]=cbsName; + pubs[in][1]=cbsAdd; + pubs[in][2]=cbsPhone; + System.out.println("出版社添加成功!"); + chubansgl(); + } + + } + + private static void shanchu2() {//删除 + System.out.println("请输入要删除的出版社名称:"); + String shan2 = scan.next(); + //找重 + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (shan2.equals(pubs[i][0])) { + pubs[i][0] = null; + pubs[i][1] = null; + pubs[i][2] = null; + System.out.println("删除成功!"); + flag = true; + break; + } + } + if (flag) { + chubansgl(); + }else { + System.out.println("没有找到该出版社!\\r\\n\"+\"删除失败!"); + chubansgl(); + } + } + + private static void gengxin2() {//更新 + System.out.println("请输入要更新的出版社名称:"); + String gxName = scan.next(); + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (gxName.equals(pubs[i][0])) { + pubs[i][1] = null; + pubs[i][2] = null; + + System.out.println("请输入新的出版社地址:"); + pubs[i][1] = scan.next(); + System.out.println("请输入新的出版社联系人:"); + pubs[i][2] = scan.next(); + System.out.println("更新成功!"); + flag = true; + break; + } + } + + if (flag) { + chubansgl(); + }else { + System.out.println("该出版社不存在!!!"); + chubansgl(); + } + } + private static void chubanshemccx() {//根据出版社名称查询 + System.out.println("输入出版社名称:"); + String cxName = scan.next(); + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (cxName.equals(pubs[i][0])) { + System.out.println("出版社名称:"+pubs[i][0]); + System.out.println("出版社地址:"+pubs[i][1]); + System.out.println("出版社联系人:"+pubs[i][2]); + flag = true; + break; + } + } + if (flag) { + shujiguanli(); + }else { + System.out.println("该出版社不存在:"); + shujiguanli(); + } + + } + private static void cbssuoyoucx() {//查询所有出版社 + System.out.print("出版社名称 \t"+"地址 \t"+"联系人 \t"); + System.out.println(); + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0]!=null) { + System.out.print(pubs[i][0]+"\t"); + System.out.print(pubs[i][1]+"\t"); + System.out.print(pubs[i][2]+"\t"); + System.out.println(); + } + } + shujiguanli(); + } + + + private static void yonghuzhuche() { + //注册 + System.out.println("请输入所属部门:"); + String zcName = scan.next(); + System.out.println("请输入用户名:"); + String dlName = scan.next(); + System.out.println("请输入密码:"); + String dlPassword = scan.next(); + //找空值 + int in = -1; + for (int i = 0; i < uesr.length; i++) { + if (uesr[i][0] == null) { + in = i; + break; + } + } + //赋值 + uesr[in][0] = zcName; + uesr[in][1] = dlName; + uesr[in][2] = dlPassword; + System.out.println("注册成功!"); + yonghudenglu(); + } + private static void xinxiluru() { + //信息录入 + + //用户信息 + uesr[0][0]="行政部";//部门 + uesr[0][1]="abc";//用户名 + uesr[0][2]="1234";//密码 + uesr[0][3]="管理员";//用户角色 + + uesr[1][0]="开发部"; + uesr[1][1]="efg"; + uesr[1][2]="1235"; + uesr[1][3]="员工"; + + uesr[1][0]="a"; + uesr[1][1]="a"; + uesr[1][2]="a"; + uesr[1][3]="a"; + + books[0][0]="1024";//编码(ISBN) + books[0][1]="十年";//书籍名称 + books[0][2]="36.5";//价格 + books[0][3]="磨铁";//出版社 + books[0][4]="南派三叔";//作者 + + books[1][0]="1026"; + books[1][1]="归路"; + books[1][2]="26.9"; + books[1][3]="阅文"; + books[1][4]="墨宝非宝"; + + pubs[0][0]="磨铁";//出版社名称 + pubs[0][1]="上海";//地址 + pubs[0][2]="abc";//联系人 + + pubs[1][0]="简图"; + pubs[1][1]="上海"; + pubs[1][2]="工作室"; + } +} diff --git "a/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.java" "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.java" new file mode 100644 index 0000000000000000000000000000000000000000..06965deeaaebca8b1cac2b99a92e6a3279935442 --- /dev/null +++ "b/Java\351\241\271\347\233\256_\347\274\226\350\257\221\347\211\210/\347\254\2542\345\260\217\347\273\204/\345\210\230\351\237\265\345\251\267/Dome04.java" @@ -0,0 +1,581 @@ +package com.md.lession; + +import java.util.Scanner; + +public class Dome04 { + //用户信息(部门、用户名、密码、用户角色) + static String uesr[][] = new String [100][4]; + //书籍信息(编码(ISBN)、书籍名称、价格、出版社、作者) + static String books[][] = new String [100][5]; + //出版社信息(出版社名称、地址、联系人) + static String pubs [][]=new String [100][3]; + //信息扫描 + static Scanner scan = new Scanner(System.in); + static String dengluUsers = ""; + public static void main(String[] args) { + xinxiluru(); + TSGL(); + + } + private static void TSGL() { + while (true) { + System.out.println("欢迎来到闽大图书管理系统!"); + System.out.println("1.登录 2.注册"); + int key = scan.nextInt(); + + switch (key) { + case 1://登录 + yonghudenglu(); + break; + case 2://注册 + yonghuzhuche(); + break; + default: + break; + } + break; + } + } + private static void yonghudenglu() { + //登录 + System.out.println("请输入用户名:"); + String dlName = scan.next(); + System.out.println("请输入密码:"); + String dlPassword = scan.next(); + + boolean flag = false; + for (int i = 0; i < uesr.length; i++) { + if (dlName.equals(uesr[i][1]) && dlPassword.equals(uesr[i][2])) { + flag = true; + break; + } + } + if (flag) { + System.out.println("登录成功!"); + dengluUsers=dlName; + shujiguanli(); + }else { + System.out.println("该用户不存在或者密码错误!请重新登录!"); + yonghudenglu(); + } + } + private static void shujiguanli() { + System.out.println(dengluUsers+",欢迎使用闽大书籍管理系统"); + System.out.println("请输入数字进行选择:1.图书管理 2.出版社管理 3.退出登录 4.退出系统"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //图书管理 + bookgl(); + break; + case 2: + //出版社管理 + chubansgl(); + break; + case 3: + //退出登录 + System.out.println("已退出登录!"); + TSGL(); + break; + case 4: + //退出系统 + System.out.println("已退出系统!"); + break; + default: + break; + } + } + private static void bookgl() { + System.out.println("请输入:1.增加 2.删除 3.更新 4.查询 5.返回上一级菜单"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //增加 + zhengjia(); + break; + case 2: + //删除 + shanchu(); + break; + case 3: + //更新 + gengxin(); + break; + case 4: + //查询 + chaxun(); + break; + case 5: + //返回上一级菜单 + shujiguanli(); + break; + default: + break; + } + } + private static void zhengjia() {//增加 + System.out.println("请输入图书ISBN:"); + String bianhao = scan.next(); + System.out.println("请输入书名:"); + String shuming = scan.next(); + System.out.println("请输入价格:"); + String jiage = scan.next(); + System.out.println("请输入出版社:"); + String chubanshe = scan.next(); + System.out.println("请输入作者:"); + String zuozhe = scan.next(); + + //找重 + boolean flag=false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + flag=true; + break; + } + } + if (flag) { + System.out.println("图书已存在,请重新输入!"); + bookgl(); + }else { + //找空值(null) + int in=-1; + for (int i = 0; i < books.length; i++) { + if (books[i][0]==null) { + in=i; + break; + } + } + //赋值 + books[in][0]=bianhao; + books[in][1]=shuming; + books[in][2]=jiage; + books[in][3]=chubanshe; + books[in][4]=zuozhe; + System.out.println("添加成功!"); + bookgl(); + } + + } + private static void shanchu() {//删除 + System.out.println("请输入要删除的书本名称:"); + String shan = scan.next(); + //找重 + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shan.equals(books[i][0])) { + books[i][0] = null; + books[i][1] = null; + books[i][2] = null; + books[i][3] = null; + books[i][4] = null; + System.out.println("删除成功!"); + flag = true; + break; + } + } + if (flag) { + bookgl(); + }else { + System.out.println("没有找到该书!\\r\\n\"+\"删除失败!"); + bookgl(); + } + } + private static void gengxin() {//更新 + System.out.println("请输入ISBN号:"); + String bianhao = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + books[i][1] = null; + books[i][2] = null; + books[i][3] = null; + books[i][4] = null; + + System.out.println("请输入新的书名:"); + books[i][1] = scan.next(); + System.out.println("请输入新的价格:"); + books[i][2] = scan.next(); + System.out.println("请输入新的出版社:"); + books[i][3] = scan.next(); + System.out.println("请输入新的作者:"); + books[i][4] = scan.next(); + System.out.println("更新成功!"); + flag = true; + break; + } + } + + if (flag) { + bookgl(); + }else { + System.out.println("该ISBN号不存在!!!"); + bookgl(); + } + + } + private static void chaxun() {//查询 + System.out.println("1.isbn 2.书名(模糊) 3.出版社 4. 作者 5. 价格范围 6.查询所有 7.返回上一级"); + int key = scan.nextInt(); + + switch (key) { + case 1://isbn + isbncx(); + break; + case 2://书名(模糊) + shumingcx(); + break; + case 3://出版社 + chubanscx(); + break; + case 4:// 作者 + zuozhecx(); + break; + case 5:// 价格范围 + jiagecx(); + break; + case 6://查询所有 + suoyoucx(); + break; + case 7://返回上一级 + bookgl(); + break; + default: + break; + } + + } + private static void isbncx() {//isbn + System.out.println("请输入ISBN号:"); + String bianhao = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (bianhao.equals(books[i][0])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("该ISBN号不存在!!!"); + chaxun(); + } + } + private static void shumingcx() {//书名(模糊) + System.out.println("请输入要查询的书名:"); + String shuming = scan.next(); + System.out.println("ISBN \t" + "书名 \t\t" + "价格 \t" + "出版社 \t" + "作者 \t\t"); + for (int i = 0; i < books.length; i++) { + if (books[i][1] != null && books[i][1].indexOf(shuming) != -1) { + System.out.println(books[i][0] + "\t" + books[i][1] + "\t" + books[i][2] + "\t" + books[i][3] + "\t" + + books[i][4] + "\t"); + } + } + chaxun(); + } + private static void chubanscx() {//出版社 + System.out.println("请输入出版社名称:"); + String shuming = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shuming.equals(books[i][3])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("该出版社不存在!!!"); + chaxun(); + } + } + + private static void zuozhecx() {// 作者 + System.out.println("请输入作者名字:"); + String shuming = scan.next(); + boolean flag = false; + for (int i = 0; i < books.length; i++) { + if (shuming.equals(books[i][4])) { + System.out.println("ISBN 书名 价格 出版社 作者 "); + System.out.println(books[i][0]+" "+books[i][1]+" "+books[i][2]+" "+books[i][3]+" "+books[i][4]); + flag = true; + break; + } + } + + if (flag) { + chaxun(); + }else { + System.out.println("没有该作者!!!"); + chaxun(); + } + } + private static void jiagecx() {// 价格范围 + System.out.println("请输入最小价格:"); + double xiao = scan.nextDouble(); + System.out.println("请输入最大价格:"); + double da = scan.nextDouble(); + + boolean flag = false; + + for (int i = 0; i < books.length; i++) { + if (books[i][0]!=null) { + double price = Double.parseDouble(books[i][2]); + if (price >= xiao && price <= da) { + for (int j = 0; j < books[i].length; j++) { + System.out.println(books[i][j]+"\t"); + flag=true; + } + }else { + System.out.println("没有书在这个价格之间!"); + } + } + } + chaxun(); + } + private static void suoyoucx() {//查询所有 + System.out.print("ISBN \t "+"书名 \t"+"价格 \t"+"出版社 \t"+"作者 \t"); + System.out.println(); + for (int i = 0; i < books.length; i++) { + if (books[i][0]!=null) { + System.out.print(books[i][0]+"\t"); + System.out.print(books[i][1]+"\t"); + System.out.print(books[i][2]+"\t"); + System.out.print(books[i][3]+"\t"); + System.out.print(books[i][4]+"\t"); + System.out.println(); + } + } + chaxun(); + } + + + + private static void chubansgl() { + System.out.println("请输入:1.增加 2.删除 3.更新 4.根据出版社名称查询 5.查询所有出版社 6.返回上一级菜单"); + int key = scan.nextInt(); + + switch (key) { + case 1: + //增加 + zhengjia2(); + break; + case 2: + //删除 + shanchu2(); + break; + case 3: + //更新 + gengxin2(); + break; + case 4: + chubanshemccx(); + //根据出版社名称查询 + break; + case 5: + cbssuoyoucx(); + //查询所有出版社 + break; + case 6: + //返回上一级菜单 + shujiguanli(); + break; + default: + break; + } + } + private static void zhengjia2() {//增加 + System.out.println("请输入出版社名称:"); + String cbsName = scan.next(); + System.out.println("请输入出版社地址:"); + String cbsAdd = scan.next(); + System.out.println("请输入出版社联系人:"); + String cbsPhone = scan.next(); + + //找重 + boolean flag=false; + for (int i = 0; i < pubs.length; i++) { + if (cbsName.equals(pubs[i][0])) { + flag=true; + break; + } + } + if (flag) { + System.out.println("出版社已存在,请重新输入!"); + chubansgl(); + }else { + //找空值(null) + int in=-1; + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0]==null) { + in=i; + break; + } + } + //赋值 + pubs[in][0]=cbsName; + pubs[in][1]=cbsAdd; + pubs[in][2]=cbsPhone; + System.out.println("出版社添加成功!"); + chubansgl(); + } + + } + + private static void shanchu2() {//删除 + System.out.println("请输入要删除的出版社名称:"); + String shan2 = scan.next(); + //找重 + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (shan2.equals(pubs[i][0])) { + pubs[i][0] = null; + pubs[i][1] = null; + pubs[i][2] = null; + System.out.println("删除成功!"); + flag = true; + break; + } + } + if (flag) { + chubansgl(); + }else { + System.out.println("没有找到该出版社!\\r\\n\"+\"删除失败!"); + chubansgl(); + } + } + + private static void gengxin2() {//更新 + System.out.println("请输入要更新的出版社名称:"); + String gxName = scan.next(); + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (gxName.equals(pubs[i][0])) { + pubs[i][1] = null; + pubs[i][2] = null; + + System.out.println("请输入新的出版社地址:"); + pubs[i][1] = scan.next(); + System.out.println("请输入新的出版社联系人:"); + pubs[i][2] = scan.next(); + System.out.println("更新成功!"); + flag = true; + break; + } + } + + if (flag) { + chubansgl(); + }else { + System.out.println("该出版社不存在!!!"); + chubansgl(); + } + } + private static void chubanshemccx() {//根据出版社名称查询 + System.out.println("输入出版社名称:"); + String cxName = scan.next(); + boolean flag = false; + for (int i = 0; i < pubs.length; i++) { + if (cxName.equals(pubs[i][0])) { + System.out.println("出版社名称:"+pubs[i][0]); + System.out.println("出版社地址:"+pubs[i][1]); + System.out.println("出版社联系人:"+pubs[i][2]); + flag = true; + break; + } + } + if (flag) { + shujiguanli(); + }else { + System.out.println("该出版社不存在:"); + shujiguanli(); + } + + } + private static void cbssuoyoucx() {//查询所有出版社 + System.out.print("出版社名称 \t"+"地址 \t"+"联系人 \t"); + System.out.println(); + for (int i = 0; i < pubs.length; i++) { + if (pubs[i][0]!=null) { + System.out.print(pubs[i][0]+"\t"); + System.out.print(pubs[i][1]+"\t"); + System.out.print(pubs[i][2]+"\t"); + System.out.println(); + } + } + shujiguanli(); + } + + + private static void yonghuzhuche() { + //注册 + System.out.println("请输入所属部门:"); + String zcName = scan.next(); + System.out.println("请输入用户名:"); + String dlName = scan.next(); + System.out.println("请输入密码:"); + String dlPassword = scan.next(); + //找空值 + int in = -1; + for (int i = 0; i < uesr.length; i++) { + if (uesr[i][0] == null) { + in = i; + break; + } + } + //赋值 + uesr[in][0] = zcName; + uesr[in][1] = dlName; + uesr[in][2] = dlPassword; + System.out.println("注册成功!"); + yonghudenglu(); + } + private static void xinxiluru() { + //信息录入 + + //用户信息 + uesr[0][0]="行政部";//部门 + uesr[0][1]="abc";//用户名 + uesr[0][2]="1234";//密码 + uesr[0][3]="管理员";//用户角色 + + uesr[1][0]="开发部"; + uesr[1][1]="efg"; + uesr[1][2]="1235"; + uesr[1][3]="员工"; + + uesr[1][0]="a"; + uesr[1][1]="a"; + uesr[1][2]="a"; + uesr[1][3]="a"; + + books[0][0]="1024";//编码(ISBN) + books[0][1]="十年";//书籍名称 + books[0][2]="36.5";//价格 + books[0][3]="磨铁";//出版社 + books[0][4]="南派三叔";//作者 + + books[1][0]="1026"; + books[1][1]="归路"; + books[1][2]="26.9"; + books[1][3]="阅文"; + books[1][4]="墨宝非宝"; + + pubs[0][0]="磨铁";//出版社名称 + pubs[0][1]="上海";//地址 + pubs[0][2]="abc";//联系人 + + pubs[1][0]="简图"; + pubs[1][1]="上海"; + pubs[1][2]="工作室"; + } +}