当前位置:   article > 正文

【Java+IO流】实现图书馆管理系统_javalibrary

javalibrary

目录

一:项目介绍

二:代码展示

1.Library类

2.Main类

3.第一个Person类

 4.第二个Person类

5.第三个Person类

6.第一个接口Operate

7.第二个接口Operate02

8.第三个接口Operate03

9.reader类

10.Root类

11.User类

12.Actor类

13.Book类

14.Student类

三:实现结果


一:项目介绍

【类的说明】

Library类:写了登陆系统。

Main类:Main中的主函数开启整个项目。

各个Person类:定义的人的属性,并写了属性的set,get方法。

各个operate接口:操作的接口。

Root类:继承了Person类,实现operate接口

reader类:继承了Person02类,实现operate02接口

User类:继承了Person03类,实现operate03接口

Book类:定义了书的一些属性,并且写了属性的get,set方法

Student类:定义了学生的一些属性,并且写了属性的get,set方法

Actor类:定义了借书者的一些属性,并且写了属性的get,set方法

声明:本项目是属于面向对象的编程,用到对象,类,抽象类,接口,继承,实现,数组及数组的操作,for循环,while循环,switch语句,if语句

【实现的功能介绍】:

 


二:代码展示

1.Library类

  1. import java.util.Scanner;
  2. public class Library {
  3. Scanner sc = new Scanner(System.in);
  4. //登录函数:显示登录界面进行选择登录
  5. public void login() {
  6. int count = 0;
  7. Person p = null;
  8. Person02 p2=null;
  9. Person03 p3=null;
  10. while (count < 2) {
  11. System.out.println("===============山农图书管理系统===============");
  12. System.out.println("请登录: 1.管理员登录 2.退出系统");
  13. int n = sc.nextInt();
  14. //通过输入的值进行登录判断
  15. if (n == 2) {
  16. return;
  17. }
  18. switch (n) {
  19. case 1:
  20. System.out.println("请输入管理员姓名:");
  21. String Rname = sc.next();
  22. System.out.println("请输入性别:");
  23. String Rsex = sc.next();
  24. System.out.println("请输入年龄:");
  25. int Rage = sc.nextInt();
  26. p = new Root(Rname,Rsex,Rage);//构造管理员对象
  27. //
  28. // System.out.println("请输入管理员姓名:");
  29. // String rname = sc.next();
  30. // System.out.println("请输入性别:");
  31. // String rsex = sc.next();
  32. // System.out.println("请输入年龄:");
  33. // int rage = sc.nextInt();
  34. p2 = new reader(Rname,Rsex,Rage);
  35. p3 = new User(Rname,Rsex,Rage);
  36. System.out.println("登录成功!");
  37. System.out.println("当前管理员:"+"姓名:" + p.getName() + " "+"性别:" + p.getSex() + " "+"年龄" + p.getAge());
  38. while(true){
  39. System.out.println("请输入你的操作:1.图书信息 2.读者信息 3.图书借阅");
  40. int m=sc.nextInt();
  41. if (m == 1) {
  42. System.out.println("请输入你的操作: 1.整理书籍 2.查阅书籍 3.增加书籍 4.删除书籍 5.显示书籍列表 6.退出");
  43. int j = sc.nextInt();
  44. if (j == 6) {
  45. System.out.println("您已成功退出!");
  46. break;
  47. } else {
  48. p.operate();//调用管理员的操作方法
  49. }
  50. }
  51. if (m == 2) {
  52. System.out.println("请输入你的操作:1.查询读者信息 2.读者信息修改,删除 3.添加读者信息 4.显示学生列表 5.退出" );
  53. int q=sc.nextInt();
  54. if(q==5){
  55. System.out.println("你已经成功退出!");
  56. break;
  57. } else{
  58. p2.operate02();
  59. }
  60. }
  61. if(m==3) {
  62. System.out.println("请输入你的操作:1.借阅查询 2.图书借阅 3.图书归还 4.图书借阅表 5.退出 ");
  63. int w=sc.nextInt();
  64. if(w==5){
  65. System.out.println("你已经成功退出!");
  66. break;
  67. }else{
  68. p3.operate03();
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }

2.Main类

  1. public class Main {
  2. public static void main(String[] args) {
  3. Library library = new Library(); //构造Library对象
  4. library.login(); //调用对象的登录方法。
  5. }
  6. }

3.第一个Person类

  1. abstract class Person {
  2. public String name;
  3. public String sex;
  4. public int age;
  5. /**
  6. * 默认定义6本书籍。(预留3本新书的buffer,用来添加书籍)
  7. */
  8. public static Book[] books = new Book[]{
  9. new Book(101,"西游记", "吴承恩","凤凰出版社","2003年9月1号",10,88,"名著", true),
  10. new Book(102,"红楼梦", "曹雪芹","凤凰出版社","2003年9月1号",11, 88, "名著", true),
  11. new Book(103,"三国演义", "罗贯中","凤凰出版社","2003年9月1号" ,12,88, "名著", true),
  12. new Book(104,"水浒传", "范仲淹","凤凰出版社","2003年9月1号",13, 88, "名著", true),
  13. new Book(105,"C++语言基础", "周老师", "电子工业出版社","2003年9月2号",14,35, "计算机", true),
  14. new Book(106,"Java编程思想", "王老师","电子工业出版社","2003年9月2号",15, 55, "计算机", true),
  15. new Book(),
  16. new Book(),
  17. new Book(),
  18. };
  19. public Person(String name, String sex, int age) {
  20. this.age = age;
  21. this.name = name;
  22. this.sex = sex;
  23. }
  24. public String getName() {
  25. return name;
  26. }
  27. public void setName(String name) {
  28. this.name = name;
  29. }
  30. public String getSex() {
  31. return sex;
  32. }
  33. public void setSex(String sex) {
  34. this.sex = sex;
  35. }
  36. public int getAge() {
  37. return age;
  38. }
  39. public void setAge(int age) {
  40. this.age = age;
  41. }
  42. /**
  43. * 抽象类中的抽象方法
  44. */
  45. public abstract void operate();
  46. }

 4.第二个Person类

  1. abstract class Person02 {
  2. public String name;
  3. public String sex;
  4. public int age;
  5. /*
  6. 定义四名学生,预留三个学生空位用于添加
  7. */
  8. public static Student[] students=new Student[]{
  9. new Student(201,"张三","信息学院","计算机类","一班"),
  10. new Student(202,"李四","信息学院","计算机类","二班"),
  11. new Student(203,"王五","信息学院","计算机类","三班"),
  12. new Student(204,"李华","信息学院","计算机类","四班"),
  13. new Student(),
  14. new Student(),
  15. new Student(),
  16. };
  17. public Person02(String name, String sex, int age) {
  18. this.age = age;
  19. this.name = name;
  20. this.sex = sex;
  21. }
  22. public String getName() {
  23. return name;
  24. }
  25. public void setName(String name) {
  26. this.name = name;
  27. }
  28. public String getSex() {
  29. return sex;
  30. }
  31. public void setSex(String sex) {
  32. this.sex = sex;
  33. }
  34. public int getAge() {
  35. return age;
  36. }
  37. public void setAge(int age) {
  38. this.age = age;
  39. }
  40. /**
  41. * 抽象类中的抽象方法
  42. */
  43. public abstract void operate02();
  44. }

5.第三个Person类

  1. abstract class Person03 {
  2. public String name;
  3. public String sex;
  4. public int age;
  5. /*
  6. 定义四名学生,预留三个学生空位用于添加
  7. */
  8. public static Actor[] actors=new Actor[]{
  9. new Actor(201,"张三",101,"红楼梦","2020年9月1号","2020年10月1日","2021年9月15号"),
  10. new Actor(202,"李四",102,"水浒传","2020年9月1号","2020年10月1日","2021年9月15号"),
  11. new Actor(203,"王五",103,"红楼梦","2020年9月1号","2020年10月1日","2021年9月15号"),
  12. };
  13. public Person03(String name, String sex, int age) {
  14. this.age = age;
  15. this.name = name;
  16. this.sex = sex;
  17. }
  18. public String getName() {
  19. return name;
  20. }
  21. public void setName(String name) {
  22. this.name = name;
  23. }
  24. public String getSex() {
  25. return sex;
  26. }
  27. public void setSex(String sex) {
  28. this.sex = sex;
  29. }
  30. public int getAge() {
  31. return age;
  32. }
  33. public void setAge(int age) {
  34. this.age = age;
  35. }
  36. /**
  37. * 抽象类中的抽象方法
  38. */
  39. public abstract void operate03();
  40. }

6.第一个接口Operate

  1. public interface operate { //操作的接口
  2. void select(Book[] books); //查询,查阅
  3. void delete(Book[] books);//删除,借阅
  4. void add(Book[] books); //增加,还书
  5. void list(Book[] books); //显示书列表
  6. }

7.第二个接口Operate02

  1. public interface operate02 {
  2. void select01(Student[] students); //查询,查阅
  3. void delete01(Student[] students);//删除,借阅
  4. void add01(Student[] students); //增加
  5. void list01(Student[] students); //显示学生列表
  6. }

8.第三个接口Operate03

  1. public interface operate03 {
  2. void select02(Actor[] actors); //查询,查阅
  3. void borrow02(Actor[] actors);//借阅
  4. void return02(Actor[] actors); //归还
  5. void list02(Actor[] actors); //列表
  6. }

9.reader类

  1. import java.util.Arrays;
  2. import java.util.Comparator;
  3. import java.util.Scanner;
  4. public class reader extends Person02 implements operate02{
  5. public reader(String name, String sex, int age) {
  6. //调用人基类的构造函数
  7. super(name, sex, age);
  8. }
  9. Scanner sc = new Scanner(System.in);
  10. /*
  11. 管理员的操作,读者信息
  12. */
  13. public void operate02() {
  14. System.out.print("请输入确认操作:");
  15. int i = sc.nextInt();
  16. switch (i) {
  17. case 1:
  18. //
  19. select01(students);
  20. break;
  21. case 2:
  22. //
  23. delete01(students);
  24. break;
  25. case 3:
  26. //
  27. add01(students);
  28. break;
  29. case 4:
  30. //列表
  31. list01(students);
  32. break;
  33. default:
  34. System.out.println("输入有误!");
  35. break;
  36. }
  37. }
  38. //查询学生信息
  39. public void select01(Student[] students){
  40. System.out.println("请输入学生名进行查询:");
  41. String name = sc.next();
  42. if (name != null) {
  43. boolean flag = false;
  44. int studentNum = 0;
  45. for (int i = 0; i < students.length; i++) {
  46. if (students[i].getName() != null && name.equals(students[i].getName())) {
  47. flag = true;
  48. studentNum = i;
  49. break;
  50. }
  51. }
  52. if (!flag) {
  53. System.out.println("未查询到此学生!");
  54. } else {
  55. System.out.println("学生信息为:" + "\n" + "【学号】---【性名】—— 【学院】——【专业】---【班级】");
  56. System.out.println(
  57. "【"+ students[studentNum].getNum()+"】---【" + students[studentNum].getName() + "】—— " +
  58. "【" + students[studentNum].getName() + "】---【"+students[studentNum].getColl()+"】---【" + students[studentNum].getMajor()+"】---" +
  59. "【"+students[studentNum].getClb()+"】"
  60. );
  61. }
  62. }
  63. }
  64. //读者信息删除修改
  65. public void delete01(Student[] students){
  66. System.out.println("请输入要删除的学生姓名:");
  67. String str = sc.next();
  68. if (str != null) {
  69. for (int i = 0; i < students.length; i++) {
  70. if (students[i].getName().equals(str)) {
  71. students[i] = null;
  72. System.out.println("删除成功!");
  73. break;
  74. }
  75. }
  76. }
  77. }
  78. //添加读者信息
  79. public void add01(Student[] students) {
  80. System.out.println("请输入学号:");
  81. int num = sc.nextInt();
  82. System.out.println("请输入学生名:");
  83. String name = sc.next();
  84. System.out.println("请输入学院:");
  85. String coll = sc.next();
  86. System.out.println("请输入专业:");
  87. String major = sc.next();
  88. System.out.println("请输入班级:");
  89. String clb = sc.next();
  90. boolean flag = false;
  91. for (int i = 0; i < students.length; i++) {
  92. if (students[i].getName() == null) {
  93. flag = true;
  94. students[i].setNum(num);
  95. students[i].setName(name);
  96. students[i].setColl(coll);
  97. students[i].setMajor(major);
  98. students[i].setClb(clb);
  99. System.out.println("学号:" +num+" "+"学生名:"+name+" "+"学院:"
  100. +coll+" "+ "专业:"+major+" "+"班级:"+clb);
  101. System.out.println("添加成功");
  102. break;
  103. }
  104. }
  105. if (!flag) {
  106. System.out.println("【警告】数组预留buffer最多只能添加3本新书,没有位置放置新书了,如需添加多余3本,需要在‘Person’类中添加buffer!" + "\n");
  107. }
  108. }
  109. //列出学生列表
  110. public void list01(Student[] students) {
  111. System.out.println("图书列表如下:" + "\n" + "【学号】---【学生姓名】—— 【学院】——【专业】---【班级】"); //打印Student数组
  112. for (int i = 0; i < students.length; i++) {
  113. if (students[i] != null) {
  114. if (students[i].num != 0) {
  115. System.out.println(
  116. "【"+students[i].getNum()+"】---【" + students[i].getName() + "】—— 【" + students[i].getColl() + "】——" +
  117. "【"+students[i].getMajor()+"】---【"+students[i].getClb()+"】");
  118. }
  119. }
  120. }
  121. }
  122. }

10.Root类

  1. import java.util.Arrays;
  2. import java.util.Comparator;
  3. import java.util.Scanner;
  4. public class Root extends Person implements operate {
  5. //继承了人的类,需要重写它的抽象方法operate,实现了operate接口,需要重写接口内的方法
  6. public Root(String name, String sex, int age) {
  7. //调用人基类的构造函数
  8. super(name, sex, age);
  9. }
  10. Scanner sc = new Scanner(System.in);
  11. /**
  12. * 管理员的操作,图书信息
  13. */
  14. @Override
  15. public void operate() {
  16. System.out.print("请输入确认操作:");
  17. int i = sc.nextInt();
  18. switch (i) {
  19. case 1:
  20. //整理
  21. sort(books);
  22. break;
  23. case 2:
  24. //
  25. select(books);
  26. break;
  27. case 3:
  28. //
  29. add(books);
  30. break;
  31. case 4:
  32. //
  33. delete(books);
  34. break;
  35. case 5:
  36. //列表
  37. list(books);
  38. break;
  39. default:
  40. System.out.println("输入有误!");
  41. break;
  42. }
  43. }
  44. /**
  45. * compareable整理,重写compare to,如果数组中有空的,则会出现空指针异常,把不空的拷到另一个新的数组,然后实现
  46. * @param books
  47. */
  48. public void sort(Book[] books) {
  49. System.out.println("图书馆中的书按价格整理如下:" + "\n" + "【书号】---【书名】—— 【作者】——【出版社】---【出版日期】---【存馆数量】---【定价】");
  50. Arrays.sort(books, new Comparator<Book>() {
  51. @Override
  52. public int compare(Book o1, Book o2) {
  53. return (int) (o1.getPrice() - o2.getPrice());
  54. }
  55. });
  56. //遍历数组打印书的列表
  57. for (int i = 0; i < books.length; i++) {
  58. if (books[i].price != 0) {
  59. System.out.println(
  60. "【"+books[i].getNum()+"】---【" + books[i].getName() + "】—— 【" + books[i].getAuthor() + "】——" +
  61. "【"+books[i].getPress()+"】---【"+books[i].getDate()+"】---【"+books[i].getTotal()+"】---【" + books[i].getPrice()
  62. + "】——【" + books[i].getCategory() + "】——" + books[i].getState());
  63. }
  64. }
  65. }
  66. @Override
  67. public void select(Book[] books) {
  68. System.out.println("请输入书名进行查询:");
  69. String name = sc.next();
  70. if (name != null) {
  71. boolean flag = false;
  72. int bookNum = 0;
  73. for (int i = 0; i < books.length; i++) {
  74. if (books[i].getName() != null && name.equals(books[i].getName())) {
  75. flag = true;
  76. bookNum = i;
  77. break;
  78. }
  79. }
  80. if (!flag) {
  81. System.out.println("未查询到此书籍!");
  82. } else {
  83. System.out.println("书籍信息为:" + "\n" + "【书号】---【书名】—— 【作者】——【出版社】---【出版日期】---【存馆数量】---【定价】");
  84. System.out.println(
  85. "【"+ books[bookNum].getNum()+"】---【" + books[bookNum].getName() + "】—— " +
  86. "【" + books[bookNum].getAuthor() + "】---【"+books[bookNum].getPress()+"】---【" + books[bookNum].getDate()+"】---" +
  87. "【"+books[bookNum].getTotal()+"】" +
  88. "——【" + books[bookNum]
  89. .getPrice() + "】——【" + books[bookNum].getCategory() + "】——" + books[bookNum]
  90. .getState());
  91. }
  92. }
  93. }
  94. @Override
  95. public void delete(Book[] books) {
  96. System.out.println("请输入要删除的书名:");
  97. String str = sc.next();
  98. if (str != null) {
  99. for (int i = 0; i < books.length; i++) {
  100. if (books[i].getName().equals(str)) {
  101. books[i] = null;
  102. System.out.println("删除成功!");
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. @Override
  109. public void add(Book[] books) {
  110. System.out.println("请输入书号:");
  111. int num = sc.nextInt();
  112. System.out.println("请输入书名:");
  113. String name = sc.next();
  114. System.out.println("请输入作者:");
  115. String author = sc.next();
  116. System.out.println("请输入出版社:");
  117. String press = sc.next();
  118. System.out.println("请输入存馆数量:");
  119. int total = sc.nextInt();
  120. System.out.println("请输入价格:");
  121. double price = sc.nextDouble();
  122. boolean flag = false;
  123. for (int i = 0; i < books.length; i++) {
  124. if (books[i].getName() == null) {
  125. flag = true;
  126. books[i].setName(name);
  127. books[i].setAuthor(author);
  128. books[i].setPress(press);
  129. books[i].setTotal(total);
  130. books[i].setPrice(price);
  131. books[i].setState(true);
  132. System.out.println("添加成功");
  133. break;
  134. }
  135. }
  136. if (!flag) {
  137. System.out.println("【警告】数组预留buffer最多只能添加3本新书,没有位置放置新书了,如需添加多余3本,需要在‘Person’类中添加buffer!" + "\n");
  138. }
  139. }
  140. @Override
  141. public void list(Book[] books) {
  142. System.out.println("图书列表如下:" + "\n" + "【书号】---【书名】—— 【作者】——【出版社】---【出版日期】---【存馆数量】---【定价】"); //打印Book数组
  143. for (int i = 0; i < books.length; i++) {
  144. if (books[i] != null) {
  145. if (books[i].price != 0) {
  146. System.out.println(
  147. "【"+books[i].getNum()+"】---【" + books[i].getName() + "】—— 【" + books[i].getAuthor() + "】——" +
  148. "【"+books[i].getPress()+"】---【"+books[i].getDate()+"】---【"+books[i].getTotal()+"】---【" + books[i].getPrice()
  149. + "】——【" + books[i].getCategory() + "】——" + books[i].getState());
  150. }
  151. }
  152. }
  153. }
  154. }

11.User类

  1. import java.util.Scanner;
  2. public class User extends Person03 implements operate03 { //user类继承了人的类, 实现operate接口
  3. public User(String name, String sex, int age) {
  4. //调用人基类的构造函数(派生类不继承基类的构造函数)
  5. super(name, sex, age);
  6. }
  7. Scanner sc = new Scanner(System.in);
  8. @Override
  9. public void operate03() { //普通用户的操作
  10. System.out.print("请输入确认操作:");
  11. int i = sc.nextInt();
  12. switch (i) {
  13. case 1:
  14. //
  15. select02(actors);
  16. break;
  17. case 2:
  18. //
  19. borrow02(actors);
  20. break;
  21. case 3:
  22. //
  23. return02(actors);
  24. break;
  25. case 4:
  26. //列表
  27. list02(actors);
  28. break;
  29. default:
  30. System.out.println("输入有误!");
  31. break;
  32. }
  33. }
  34. @Override
  35. public void select02(Actor[] actors) {
  36. System.out.println("请输入书名进行查询:");
  37. String bookme = sc.next();
  38. if (bookme != null) {
  39. boolean flag = false;
  40. int actorNum = 0;
  41. for (int i = 0; i < actors.length; i++) {
  42. if (actors[i].getBookme() != null && bookme.equals(actors[i].getBookme())) {
  43. flag = true;
  44. actorNum = i;
  45. break;
  46. }
  47. }
  48. if (!flag) {
  49. System.out.println("未查询到此书籍!");
  50. } else {
  51. System.out.println("书籍信息为:" + "\n" + "【学号】---【姓名】—— 【书号】——【书名】---【借阅日期】---【应还日期】---【归还日期】");
  52. System.out.println(
  53. "【" + actors[actorNum].getNum() + "】—— 【" + actors[actorNum].getName() + "】——【" + actors[actorNum]
  54. .getVolume() + "】——【" +actors[actorNum].getBookme() + "】——" +actors[actorNum]
  55. .getBodate()+"】——【"+actors[actorNum].getSrdate()+"】——【"+actors[actorNum].getRedate()+" 】"+actors[actorNum].getState() );
  56. }
  57. }
  58. }
  59. @Override
  60. public void borrow02(Actor[] actors) {
  61. System.out.println("请输入要借阅的书名:");
  62. String bookme = sc.next();
  63. if (bookme != null) {
  64. for (int i = 0; i < actors.length - 1; i++) {
  65. if (actors[i].getBookme().equals(bookme)) {
  66. //借走书时设置状态为false
  67. if (!actors[i].getState()) {
  68. System.out.println("【" + bookme + "】" + "已经被借出!");
  69. } else {
  70. actors[i].setState(false);
  71. System.out.println("借阅成功!");
  72. }
  73. break;
  74. }
  75. }
  76. }
  77. }
  78. @Override
  79. public void return02(Actor[] actors) {
  80. System.out.println("请输入要还的书名:");
  81. String bookme = sc.next();
  82. if (bookme != null) {
  83. boolean flag = true;
  84. int i = 0;
  85. while (flag) {
  86. if (actors[i].getBookme().equals(bookme)) {
  87. if (!actors[i].getState()) {
  88. actors[i].setState(true);
  89. System.out.println("还书成功!");
  90. flag = false;
  91. } else {
  92. System.out.println("该书籍已经被还回!");
  93. break;
  94. }
  95. }
  96. i++;
  97. }
  98. }
  99. }
  100. @Override
  101. public void list02(Actor[] actors) {
  102. System.out.println("借书列表如下:" + "\n" + "【学号】—— 【姓名】——【书号】——【书名】——【借阅日期】——【应还日期】——【归还日期】——状态"); //打印Book数组
  103. for (int i = 0; i < actors.length; i++) {
  104. if (actors[i] != null) {
  105. if (actors[i].num != 0) {System.out.println(
  106. "【" + actors[i].getNum() + "】—— 【" + actors[i].getName() + "】——【" + actors[i].getVolume()
  107. + "】——【" + actors[i].getBookme() + "】——" + actors[i].getBodate()+"】——"+actors[i].getSrdate()+"】——"+actors[i].getRedate() );
  108. }
  109. }
  110. }
  111. }
  112. }

12.Actor类

  1. public class Actor {
  2. public int num; //学号
  3. public String name; //姓名
  4. public int volume; //书号
  5. public String bookme; //书名
  6. public String bodate; //借阅日期
  7. public String srdate; //应还日期
  8. public String redate; //归还日期
  9. private boolean state; //状态 true-未借出 false-已借出
  10. public Actor(int num,String name,int volume,String bookme,String bodate,String srdate,String redate){
  11. this.num=num;
  12. this.name=name;
  13. this.volume=volume;
  14. this.bookme=bookme;
  15. this.bodate=bodate;
  16. this.srdate=srdate;
  17. this.redate=redate;
  18. this.state = state;
  19. }
  20. public Actor(){this(7);}
  21. public Actor(int i){Person03.actors=new Actor[i];}
  22. public int getNum(){
  23. return num;
  24. }
  25. public void setNum(int num){
  26. this.num=num;
  27. }
  28. public String getName(){
  29. return name;
  30. }
  31. public void setName(String name){
  32. this.name=name;
  33. }
  34. public int getVolume(){
  35. return volume;
  36. }
  37. public void setVolume(int volume){
  38. this.volume=volume;
  39. }
  40. public String getBookme(){
  41. return bookme;
  42. }
  43. public void setBookme(String bookme){
  44. this.bookme=bookme;
  45. }
  46. public String getBodate(){return bodate;}
  47. public void setBodate(String bodate){this.bodate=bodate;}
  48. public String getSrdate(){return srdate;}
  49. public void setSrdate(String srdate){this.srdate=srdate;}
  50. public String getRedate(){return redate;}
  51. public void setRedate(String redate){this.redate=redate;}
  52. public boolean getState() {
  53. return state;
  54. }
  55. public void setState(boolean state) {
  56. this.state = state;
  57. }
  58. }

13.Book类

  1. public class Book{
  2. public int num; //书号
  3. public String name; //书名
  4. public String author; //作者
  5. public String press; //出版社
  6. public String date; //出版日期
  7. public int total; //存馆数量
  8. public double price; //价格
  9. public String category; //分类
  10. public boolean state; //状态 true-未借出 false-已借出
  11. //通过构造函数给定书的属性
  12. public Book(int num,String name,String author,String press,String date,int total,double price,String category,boolean state){
  13. this.num=num;
  14. this.press=press;
  15. this.date=date;
  16. this.total=total;
  17. this.author = author;
  18. this.name = name;
  19. this.price = price;
  20. this.category = category;
  21. this.state = state;
  22. }
  23. public Book() { //默认10本书
  24. this(6);
  25. }
  26. public Book(int i) {
  27. Person.books = new Book[i];
  28. }
  29. //属性的获取和设置
  30. public int getNum(){
  31. return num;
  32. }
  33. public void getNum(int num){
  34. this.num=num;
  35. }
  36. public String getPress(){
  37. return press;
  38. }
  39. public void setPress(String press){
  40. this.press=press;
  41. }
  42. public String getDate(){
  43. return date;
  44. }
  45. public void setDate(String date){
  46. this.date=date;
  47. }
  48. public int getTotal(){
  49. return total;
  50. }
  51. public void setTotal(int total){
  52. this.total=total;
  53. }
  54. public String getName() {
  55. return name;
  56. }
  57. public void setName(String name) {
  58. this.name = name;
  59. }
  60. public String getAuthor() {
  61. return author;
  62. }
  63. public void setAuthor(String author) {
  64. this.author = author;
  65. }
  66. public double getPrice() {
  67. return price;
  68. }
  69. public void setPrice(double price) {
  70. this.price = price;
  71. }
  72. public String getCategory() {
  73. return category;
  74. }
  75. public void setCategory(String category) {
  76. this.category = category;
  77. }
  78. public boolean getState() {
  79. return state;
  80. }
  81. public void setState(boolean state) {
  82. this.state = state;
  83. }
  84. }

14.Student类

  1. public class Student {
  2. public int num; //学号
  3. public String name; //姓名
  4. public String coll; //学院
  5. public String major; //专业
  6. public String clb; //班级
  7. public Student(int num,String name,String coll,String major,String clb){
  8. this.num=num;
  9. this.name=name;
  10. this.coll=coll;
  11. this.major=major;
  12. this.clb=clb;
  13. }
  14. public Student(){this(5);}
  15. public Student(int i){Person02.students=new Student[i];}
  16. public int getNum(){
  17. return num;
  18. }
  19. public void setNum(int num){
  20. this.num=num;
  21. }
  22. public String getName(){
  23. return name;
  24. }
  25. public void setName(String name){
  26. this.name=name;
  27. }
  28. public String getColl(){
  29. return coll;
  30. }
  31. public void setColl(String coll){
  32. this.coll=coll;
  33. }
  34. public String getMajor(){
  35. return major;
  36. }
  37. public void setMajor(String major){
  38. this.major=major;
  39. }
  40. public String getClb(){
  41. return clb;
  42. }
  43. public void setClb(String clb){ this.clb=clb;
  44. }
  45. }

三:实现结果

1.登陆界面

 2.图书信息界面

 3.读者信息界面

 4.图书借阅界面

 如有错误敬请评论指正!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/556063
推荐阅读
相关标签
  

闽ICP备14008679号