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