資源描述:
《Java圖書圖書管理系統(tǒng)報告.doc》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、成都信息工程學(xué)院計算機(jī)學(xué)院課程實(shí)驗(yàn)報告實(shí)驗(yàn)課程:Java程序設(shè)計實(shí)驗(yàn)項(xiàng)目:圖書管理系統(tǒng)指導(dǎo)教師:湯蓉學(xué)生姓名:向浩學(xué)生學(xué)號:2011051020班級:計科111班實(shí)驗(yàn)地點(diǎn):6306上交時間:2012年1月1229實(shí)驗(yàn)成績:29一、源代碼importjava.io.*;publicclassBookimplementsSerializable{//書的基類publicStringauthor;//作者publicStringpublished;//出版商publicStringnameOfBook;//書名privateintBooknumbers=200;publicBook(){}publi
2、cBook(Stringauthor,Stringpublished,StringnameofBook){this.author=author;this.published=published;this.nameOfBook=nameofBook;}privatevoidwriteObject(ObjectOutputStreamout)throwsIOException{out.writeUTF(author);out.writeUTF(published);out.writeUTF(nameOfBook);}privatevoidreadObject(ObjectInputStreamin
3、)throwsIOException{author=in.readUTF();published=in.readUTF();nameOfBook=in.readUTF();}privatebooleanbool=false;publicsynchronizedvoidborrowBook(){if(bool){try{wait();//多線程通信機(jī)制}catch(InterruptedExceptione){System.out.println("Book類出現(xiàn)異常");}}else{bool=false;Booknumbers--;System.out.println("目前圖書館的館藏圖書
4、一共有"+Booknumbers+"冊");notify();//其他的線程被喚醒}}publicsynchronizedvoidreturnBook(){if(bool)29{try{wait();//多線程通信機(jī)制}catch(InterruptedExceptione){System.out.println("Book類出現(xiàn)異常");}}else{bool=true;Booknumbers++;System.out.println("目前圖書館的館藏圖書一共有"+Booknumbers+"冊");notify();//通知其他的線程被喚醒}}}publicclassBorrowedBoo
5、kOutOfLimitExceptionextendsException{}//借書的數(shù)量超過了規(guī)定最大的數(shù)量拋出的異常publicclassBorrowThreadimplementsRunnable{Bookbook;publicBorrowThread(BookBo){book=Bo;}publicvoidrun(){try{book.borrowBook();Thread.sleep(10);}catch(InterruptedExceptionio){System.out.println("BorrowThread出現(xiàn)異常");}}}importjava.awt.*;importja
6、va.awt.Event.*;importjava.awt.event.MouseEvent;importjava.awt.event.MouseListener;publicclassButton1HandlerimplementsMouseListener{publicvoidmouseClicked(MouseEvente){29UserLogintft=newUserLogin();}publicvoidmouseEntered(MouseEvente){//Picture.lb3.setText("你已經(jīng)可以進(jìn)行單擊操作。。。");}publicvoidmousePressed(Mo
7、useEvente){//Picture.lb3.setText("你已按下按鈕!");}publicvoidmouseRelesed(MouseEvente){}@OverridepublicvoidmouseReleased(MouseEvente){//TODOAuto-generatedmethodstub}@OverridepublicvoidmouseExited(MouseEvent