您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > Java实验报告之图书管理系统
Java实验报告图书管理系统1.管理员界面密码验证展示所有图书查找图书添加书籍删除书籍修改密码返回上一层结束2.学生界面身份识别查找图书借阅图书归还书籍返回上一层结束3.退出程序源代码:Main.javapackagecom.company;importjava.util.Date;importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){//writeyourcodehereUserU;LibraryL=newLibrary(东北大学图书馆);System.out.println(欢迎来到东北大学图书馆);Bookb1=newBook(java编程思想,sdhf,554532,newDate(2016,12,13),15);Bookb2=newBook(C++编程,nimei,15654,newDate(2017,5,13),5);Studentss1=newUndergraduate(黎明,20175821);Studentss2=newMaster(狭隘,20164545);b1.BookUser.add(s2);b1.BookUser.add(s1);b2.BookUser.add(s2);b2.BookUser.add(s1);L.addBook(b1);L.addBook(b2);//在以上的代码中都是为了增加图书馆中的藏书Scannersc=newScanner(System.in);Stringorder;//命令操作板while(true){System.out.println(命令操作符\nAccessADInterface\nAccessSTInterface\nover);System.out.print();order=sc.next();if(order.equals(AccessADInterface)){AdministratorsA=newAdministrators();if(A.getPassWord()==1){while(true){System.out.println(命令操作符\nShowAllBook\nSearchBook\nAddBook\nDeleteBook\nChangePassWord\nGoBack\nover);System.out.print();order=sc.next();if(order.equals(ShowAllBook)){L.ShowBook();}elseif(order.equals(SearchBook)){L.ShowBook(L.SearchBook());}elseif(order.equals(AddBook)){L.addBook();}elseif(order.equals(DeleteBook)){L.DeleteBook();}elseif(order.equals(ChangePassWord)){A.changePassWord();}elseif(order.equals(GoBack)){break;}elseif(order.equals(over)){System.out.println(已退出图书管理系统);System.exit(0);}}}else{System.exit(0);}}elseif(order.equals(AccessSTInterface)){U=L.UserComing();while(true){System.out.println(SearchBook\nBorrowBook\nReturnBook\nGoBack\nover);System.out.print();order=sc.next();if(order.equals(SearchBook)){L.ShowBook(L.SearchBook());}elseif(order.equals(BorrowBook)){L.SearchBook().BookBorrow(U);}elseif(order.equals(ReturnBook)){L.ReturnBook(U);}elseif(order.equals(GoBack)){break;}}}elseif(order.equals(over)){System.out.println(已退出图书管理系统);System.exit(0);}else{System.out.println(输入了错误的指令);continue;}}}}Library.javapackagecom.company;importjava.util.Scanner;importjava.util.Vector;publicclassLibrary{publicstaticfinalintOK=1;publicstaticfinalintERROR=1;VectorObjectbook=newVector();//用来存储书类丹书类中也存有用户类privateStringLibraryname;Scannersc=newScanner(System.in);Library(Stringname){this.Libraryname=name;}publicUserUserComing(){intkind;UserU;Scannersc=newScanner(System.in);System.out.println(如果你是老师请输入1,若是学生请输入2);while(true){while(true){kind=sc.nextInt();if(kind==1){U=newTeacher();returnU;}elseif(kind==2){System.out.println(如果你是本科生请输入1,若是硕士研究生请输入2);while(true){kind=sc.nextInt();if(kind==1){U=newUndergraduate();returnU;}elseif(kind==2){U=newMaster();returnU;}else{System.out.println(输入错误);break;}}}else{System.out.println(输入错误);System.out.println(请重新输入:);break;}}}}publicvoidaddBook(Bookb){book.add(b);}publicvoidaddBook(){inti;i=1;Bookb;while(i==1){b=newBook();this.addBook(b);System.out.println(如果要继续输入书本信息就输入1,否则就输入2);i=sc.nextInt();}}publicBookSearchBook(){StringBookName;Bookb;System.out.println(请输入你要借查询的书);BookName=sc.next();for(inti=0;ithis.book.size();i++){b=(Book)this.book.elementAt(i);if(b.bookName.equals(BookName)){returnb;}}returnnull;}publicvoidReturnBook(UserU){Useru;Bookb;b=this.SearchBook();for(inti=0;ib.BookUser.size();i++){u=(User)b.BookUser.elementAt(i);if(u==U){U.numBookBor--;b.BookUser.remove(i);b.surplus++;System.out.println(还书成功);return;}else{System.out.println(您不是这本书的借阅者,不能还书);return;}}System.out.println(找不到你要的书);}publicvoidDeleteBook(){StringBookName;Bookb;System.out.println(请输入你要删除的书);BookName=sc.next();for(inti=0;ithis.book.size();i++){b=(Book)this.book.elementAt(i);if(b.bookName.equals(BookName)){if(b.BookUser.size()==0){this.book.remove(i);System.out.println(已经成功的删除书籍);}else{System.out.println(还有人尚未还书,不能够删除书籍);}}}}publicvoidShowBook(){Bookb;for(inti=0;ithis.book.size();i++){b=(Book)book.elementAt(i);System.out.println((i+1)+\t+b.bookName+\t+b.auther+\t+b.bookNum+\t+b.depositTime.getYear()+\t+b.depositTime.getMonth()+\t+b.depositTime.getDay()+\t+b.surplus);}}publicvoidShowBook(Bookb){System.out.println(\t+b.bookName+\t+b.auther+\t+b.bookNum+\t+b.depositTime.getYear()+\t+b.depositTime.getMonth()+\t+b.depositTime.getDay()+\t+b.surplus);}}Book.javapackagecom.company;importjava.util.Scanner;importjava.util.Vector;publicclassLibrary{publicstaticfinalintOK=1;publicstaticfinalintERROR=1;VectorObjectbook=newVector();//用来存储书类丹书类中也存有用户类privateStringLibraryname;Scannersc=newScanner(System.in);Library(Stringname){this.Libraryname=name;}publicUserUserComing(){intkind;UserU;Scannersc=newScanner(System.in);System.out.println(如果你是老师请输入1,若是学生请输入2);while(true){while(true){kind=sc.nextInt();if(kind==1){U=newTeacher();returnU;}elseif(kind==2){System.out.println(如果你是本科生请输入1,若是硕士研究生请输入2);while(true){kind=sc.nextInt();if(kind==1){U=newUndergraduate();returnU;}elseif(kind==2){U=newMaster();returnU;}else{System.out.println(输入错误);break;}}}else{System.out.println(输入错误);System.out.println(请重新输入:);break;}}}}publicvoidaddBook(Bookb){book.add(b);}publicvoidaddBook(){inti;i
本文标题:Java实验报告之图书管理系统
链接地址:https://www.777doc.com/doc-6517914 .html