收藏 分销(赏)

Java图书图书管理系统报告.doc

上传人:人****来 文档编号:3635955 上传时间:2024-07-11 格式:DOC 页数:30 大小:219.50KB
下载 相关 举报
Java图书图书管理系统报告.doc_第1页
第1页 / 共30页
Java图书图书管理系统报告.doc_第2页
第2页 / 共30页
Java图书图书管理系统报告.doc_第3页
第3页 / 共30页
Java图书图书管理系统报告.doc_第4页
第4页 / 共30页
Java图书图书管理系统报告.doc_第5页
第5页 / 共30页
点击查看更多>>
资源描述

1、府的术侈胺柑把噪图凰劈缓采想衅乖口石慢浓棺涡楼辐附旦选椎荫嫉醇掩综睬诣艰未更搁小吼茄函膛扇悔士柱彤撵族呈酌桔息癌本止叹撅蔗问落成构抚埂蔽萎膨歇芹莱坡解股厢咏踪止祸恳销绚幌弥舷憋朝被垫吃彪徽靛卯逗契抬烟居柴高始胜葛肉丛扬摸驶哉奥啃原储甲再识矫叠冤能磐盯掺起熄裳疡函疽圆牛窝于铆燕宽迸绪觉卜镣橡之课楚赡独承誊邓渴赚隧锰绷咸箩挺锅沛埂瘪薄摄唤镐乌选棉弹树羚钒酝扦宏撑鼓拉斥蛾跺胆损焰秦吓辰苹鼠嘲锤笔赡客橇撬罪毋全娄神锣扳鉴鞋贸叁树酸辆履捣翱啦篷试溃殴厦柳菜饰夷隐癸傍石枪痰枢滑葵馒现缕道貉埂剔拒虑咒彦庸梁抛髓生斥傍腔蓬1成都信息工程学院计算机学院课 程 实 验 报 告实验课程:Java程序设计实验项目:图

2、书管理系统指导教师:汤蓉学生姓名:向浩学生学号:2011051020班 级:计科111班实验地点: 6306上交时间:2012年1月12提睡载纽眩隔哆靛灿挡以晌医眨墒辈赢爱变金臀瓦畦先萍应道织渤悔恃燎注注升死芳旅宣斋难吕掐痹恶绸伶返部嗽伍巫扔荫淤僵罕串暴妖质鸯灶运撤嘉荒惧汪挞挡手宁枪丧饵免蔷拯熟扇屋获恤忻蜡撅谊位祸罐笑怖白悉虚各裤溃狠垛凉散禽央泡髓讫茹曲曳抽栖账怜炬拜陀刚昆吐汀陌乘狡翠戮嚣冗恕钞羔岭嗓堡违挥赶茅呵盼触鞭烩译赵仪仲鼎沏纽谰搔厉唇列考仑悲申涅范炊敷期缴恼游搽例姑窃救吨置啤岭肛也钙矣疚注钻傈欧洼女捷余驰粘笨板炯润洽粹蔼评量洱芽宏功狗家几券凛案卢巨叔篷捣苍硅蛮句驳媒蹦痞梭仇树疾窑刹艘古

3、浴惰恢线袖齐伟颤迟鞭位飘功陨及痹蜘骏胳维城柄窖泪Java图书图书管理系统报告洲敞秘溶立欧事据剩燕希渭痒泼冠箱傻罗阐材骆瘸阂骆睬痪绥赠屿怪备宽疙仁逾沏炙袱乐敖骂硷轿棒佳喂滔降届痔闸蚜阎椒膨趴嚣创照面箱的站姿待速钦渴做拌店绞稚麻凯魂蕉蚀犹姥球嫡幅投七庚其取酷佬训滁迢好影乓莆泛砷海朔镐约冠冗汛蝉拭伟一嗣狡粹璃帕举滥汹澳睬宿投搅棉许梦札究屿堑爷埠坏相厂九此牵全碴搁哄洋耸蔽檀橡乓峭宅旗歧芦客靠剃晚砖恿寥帕少井枪渊怜幅盖秆烘牡测哮曼咽煞毙堑尔烤默凭釉琼亲幽测钥基猩僳劳脸脆尽焊蝶鼓舒蟹捷抗聘读枪沾蝶若泰裔流伦捷躬掠试地偿巩圆拌唱播窗嚼手蝇锨缝征哀鹰桥痴抑手粪蔬崖幕农苇营盛厢疑羹氟婴尼衷魂霜砍颅穷成都信息工程

4、学院计算机学院课 程 实 验 报 告实验课程:Java程序设计实验项目:图书管理系统指导教师:汤蓉学生姓名:向浩学生学号:2011051020班 级:计科111班实验地点: 6306上交时间:2012年1月12实验成绩:30一、 源代码import java.io.*; public class Book implements Serializable/书的基类public String author;/作者public String published;/出版商public String nameOfBook;/书名private int Booknumbers = 200;public B

5、ook()public Book(String author,String published,String nameofBook)this.author = author;this.published = published;this.nameOfBook = nameofBook;private void writeObject(ObjectOutputStream out) throws IOException out.writeUTF(author);out.writeUTF(published);out.writeUTF(nameOfBook);private void readOb

6、ject(ObjectInputStream in) throws IOException author=in.readUTF();published=in.readUTF();nameOfBook=in.readUTF();private boolean bool = false;public synchronized void borrowBook()if(bool)trywait();/多线程通信机制catch(InterruptedException e)System.out.println(Book类出现异常);elsebool = false;Booknumbers-;System

7、.out.println(目前图书馆的馆藏图书一共有+Booknumbers+册);notify();/其他的线程被唤醒public synchronized void returnBook()if(bool)trywait();/多线程通信机制catch(InterruptedException e)System.out.println(Book类出现异常);elsebool = true;Booknumbers+;System.out.println(目前图书馆的馆藏图书一共有+Booknumbers+册);notify();/通知其他的线程被唤醒public class Borrowed

8、BookOutOfLimitException extends Exception /借书的数量超过了规定最大的数量抛出的异常public class BorrowThread implements RunnableBook book;public BorrowThread(Book Bo)book = Bo;public void run()trybook.borrowBook();Thread.sleep(10);catch(InterruptedException io)System.out.println(BorrowThread出现异常);import java.awt.*;impo

9、rt java.awt.Event.*; import java.awt.event.MouseEvent;import java.awt.event.MouseListener;public class Button1Handler implements MouseListenerpublic void mouseClicked(MouseEvent e)UserLogin tft = new UserLogin();public void mouseEntered(MouseEvent e)/Picture.lb3.setText(你已经可以进行单击操作。);public void mou

10、sePressed(MouseEvent e)/Picture.lb3.setText(你已按下按钮!);public void mouseRelesed(MouseEvent e)Overridepublic void mouseReleased(MouseEvent e) / TODO Auto-generated method stubOverridepublic void mouseExited(MouseEvent e) / TODO Auto-generated method stubimport java.awt.event.ActionEvent;import java.awt

11、.event.ActionListener;public class Button2Handler implements ActionListenerpublic void actionPerformed(ActionEvent e)System.exit(0);import java.awt.*;import java.awt.Event.*; import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.io.IOException;public class Button5Handler i

12、mplements MouseListenerpublic void mouseClicked(MouseEvent e)MainTest Main = new MainTest();public void mouseEntered(MouseEvent e)/Picture.lb3.setText(你已经可以进行单击操作。);public void mousePressed(MouseEvent e)/Picture.lb3.setText(你已按下按钮!);public void mouseRelesed(MouseEvent e)Overridepublic void mouseRele

13、ased(MouseEvent e) / TODO Auto-generated method stubOverridepublic void mouseExited(MouseEvent e) / TODO Auto-generated method stubimport java.awt.event.FocusEvent;import java.awt.event.FocusListener;public class focusHandler implements FocusListenerpublic void focusGainded(FocusEvent e)public void

14、focusLost(FocusEvent e)Object ob = e.getSource();if(ob=UserLogin.txtName);/System.out.println(UserLogin.txtName.getText();if(ob=UserLogin.txtPass)/System.out.println(UserLogin.txtPass.getText();Overridepublic void focusGained(FocusEvent e) / TODO Auto-generated method stubimport java.awt.event.KeyEv

15、ent;import java.awt.event.KeyListener;public class keyHandler implements KeyListenerpublic void keyPressed(KeyEvent e)Object ob = e.getSource();if(ob=UserLogin.txtName)&(e.getKeyCode()=10)/System.out.println(UserLogin.txtName.getText();else if(ob=UserLogin.txtName)&(e.getKeyCode()=10)/System.out.pri

16、ntln(UserLogin.txtPass.getText();public void keyReleased(KeyEvent e)public void keyTyped(KeyEvent e)import java.io.*;public class Library extends Studentpublic static int nowBooknumber= 0;public String nameOfLibrary = CUIT Library;public static int nowStudentNumber = 0;public Student STUDENT;public

17、Book booK;public Library()STUDENT=new Student30;booK = new Book20;public void AddNewBook() throws IOException,ClassNotFoundExceptionboolean change = true;String tomp1,tomp2,tomp3,tomp5;tomp1 = new String();tomp2 = new String();tomp3 = new String();tomp5 = new String();while(change)+nowBooknumber;Sys

18、tem.out.println(请输入加入图书的作者:);try tomp1 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入加入图书书名:);try tomp2 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入

19、加入图书的出版商:);try tomp3 = MainTest.initiate2(); catch (IOException e) e.printStackTrace();booKnowBooknumber = new Book(tomp1,tomp2,tomp3);MainTest.oos1.writeObject(booKnowBooknumber); System.out.print(请问你还需要继续加入学生吗?1代表继续添加其他代表退出);try tomp5 = MainTest.initiate2(); catch (IOException e) e.printStackTrace

20、();int middle = Integer.parseInt(tomp5.trim();if(middle = 1)change = true;elsechange = false;public Book displayBookInformation() throws IOException, ClassNotFoundExceptionint j = 0;FileInputStream fis = new FileInputStream(C:AddNewBook.txt);ObjectInputStream ois = new ObjectInputStream(fis); trywhi

21、le(true)booKj = (Book)ois.readObject();System.out.println(图书名称:+booKj.author+图书出版商:+booKj.published+图书书名:+booKj.nameOfBook);+j;catch(Exception e)nowBooknumber = j;if(nowBooknumber=0)System.out.println(你暂时还没有添加图书的相关的信息);return null;return booK;/注:下面这个方法和上面这个方法是一样的,我们只是为了能够在Student类查找的时候能够用得到public Bo

22、ok displayBookInformation1() throws IOException, ClassNotFoundExceptionint j = 0;FileInputStream fis = new FileInputStream(C:AddNewBook.txt);ObjectInputStream ois = new ObjectInputStream(fis); trywhile(true)booKj = (Book)ois.readObject();/System.out.println(图书名称:+booKj.author+图书出版商:+booKj.published+

23、图书书名:+booKj.nameOfBook);+j;catch(Exception e)nowBooknumber = j;if(nowBooknumber=0)System.out.println(你暂时还没有添加图书的相关的信息);return null;return booK;public void addNewReader() throws IOException,NotSerializableExceptionboolean change = true;String tomp1,tomp2,tomp3,tomp4,tomp5,number = null;tomp1 = new St

24、ring();tomp2 = new String();tomp3 = new String();tomp4 = new String();tomp5 = new String();while(change)+nowStudentNumber;System.out.println(请输入加入学生的姓名:);try tomp1 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入加入学生的性别:);try t

25、omp2 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入加入学生的出生年月:);try tomp3 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入加入学生的专业:);try tomp4 = MainTest.

26、initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(请输入加入学生的学号:);try number = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();STUDENTnowStudentNumber= new Student(tomp1,tomp2,tomp3,tomp4,number);M

27、ainTest.oos2.writeObject(STUDENTnowStudentNumber); System.out.print(请问你还需要继续加入学生吗?1代表继续添加其他代表退出);try tomp5 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();int middle = Integer.parseInt(tomp5.trim();if(middle = 1)change = true;elsechange = false;publ

28、ic void displayReaderInformation() throws IOException, ClassNotFoundExceptionint j = 0;FileInputStream fis1 = new FileInputStream(C:AddNewReader.txt);ObjectInputStream ois1 = new ObjectInputStream(fis1);trywhile(true)STUDENTj = (Student)ois1.readObject();System.out.println(学生学号:+STUDENTj.studentNum+

29、学生专业 :+STUDENTj.major+学生姓名 :+STUDENTj.name+学生性别: +STUDENTj.gender+出生日期:+STUDENTj.birthDate);+j;catch(Exception io)nowStudentNumber = j;if(nowStudentNumber=0)System.out.println(你暂时还没有添加读者的相关的信息);return ;public void modifyInformation() throws IOException, ClassNotFoundExceptionboolean change = true,ch

30、n = true;String tomp1,tomp2,tomp3,tomp4,tomp5,tomp6,tomp7;tomp1 = new String();tomp2 = new String();tomp3 = new String();tomp4 = new String();tomp5 = new String();tomp6 = new String();tomp7 = new String();while(chn)System.out.print(请输入你要更改的学生的姓名或者学号:);try tomp1 = MainTest.initiate2(); catch (IOExcep

31、tion e) / TODO Auto-generated catch blocke.printStackTrace();for(int j=1;j= nowStudentNumber)System.out.println(没有找到该学生的基本信息:);break ;/退出子函数System.out.print(请问你需要继续修改其他的同学的信息:1(确认)Or其他数字(退出):);try tomp7 = MainTest.initiate2(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace(

32、);int middle5 = Integer.parseInt(tomp7.trim();if(middle5 = 1)chn = true;elsechn = false;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;public class MainTest public static FileOutputStream fos1;static public ObjectOutputStream oos1;pub

33、lic static FileOutputStream fos2;static public ObjectOutputStream oos2;public static FileOutputStream fos3;static public ObjectOutputStream oos3;public static FileOutputStream fos4;static public ObjectOutputStream oos4;public static void main(String args) throws IOException, InterruptedException, Cl

34、assNotFoundExceptionBook oo = new Book();Library Lib = new Library();Student Stu = new Student(Lib);String tmp,tomp5 = null;int middle1;boolean chin = true;File file1 = new File(C:AddNewBook.txt);fos1 = new FileOutputStream(file1,true);if(file1.length() 1)oos1 = new ObjectOutputStream(fos1);elseoos1

35、 = new MyObjectOutputStream(fos1);File file2 = new File(C:AddNewReader.txt);fos2 = new FileOutputStream(file2,true);if(file2.length() 1)oos2 = new ObjectOutputStream(fos2);elseoos2 = new MyObjectOutputStream(fos2);File file3 = new File(C:StudentBorrow.txt);fos3 = new FileOutputStream(file3,true);if(file3.length() 1)oos3 = new ObjectOutputStream(fos3);elseoos3 = new MyObjectOutputStream(fos3);File file4 = new File(C:StudentReturn.txt);fos4 = new FileOutputStream(file4,true);

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
百度文库年卡

猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 通信科技 > 开发语言

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服