Java課程設(shè)計(jì)學(xué)生成績管理系統(tǒng)_第1頁
Java課程設(shè)計(jì)學(xué)生成績管理系統(tǒng)_第2頁
Java課程設(shè)計(jì)學(xué)生成績管理系統(tǒng)_第3頁
Java課程設(shè)計(jì)學(xué)生成績管理系統(tǒng)_第4頁
Java課程設(shè)計(jì)學(xué)生成績管理系統(tǒng)_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、1、需求分析1)功能要求:a.從圖形用戶界面中輸入學(xué)生姓名、學(xué)號、成績(4個(gè)科目),并保存到文件中(注意學(xué)號唯一性);b.根據(jù)學(xué)生學(xué)號查找學(xué)生成績,并在界面上顯示姓名、學(xué)號和成績,學(xué)號不存在的給出提示信息;c.根據(jù)學(xué)生姓名(支持不完全匹配)查找學(xué)生成績,并在界面上顯示姓名、學(xué)號和成績,如果有多個(gè)相同姓名學(xué)生存在,一起顯示出來,姓名不存在的給出提示信息;d.支持分別對所有學(xué)生各科成績畫出柱狀分布圖(參考書本相關(guān)程序);e.支持對學(xué)生信息的修改與刪除(要反映的文件中);f.支持用戶登錄、驗(yàn)證操作;g.界面要示:用圖形界面實(shí)現(xiàn)。2)具體功能的詳盡描述如下:2.1.選擇【學(xué)生登陸】菜單命令,即可進(jìn)入學(xué)

2、生賬號登陸界面,輸入相應(yīng)正確的賬號密碼即可進(jìn)行查看成績或是修改密碼。2.2.選擇【管理員登陸】菜單命令,即可進(jìn)入管理員登陸界面(本程序假定只有一個(gè)管理員,賬號與密碼在編寫程序的時(shí)候已給定,不能修改)根據(jù)錄入學(xué)生成績、根據(jù)姓名或是學(xué)號查找學(xué)生信息、刪除學(xué)生記錄、修改學(xué)生成績、并可查看整體成績的分布柱狀圖。2、總體設(shè)計(jì)(概要設(shè)計(jì))1)概要結(jié)構(gòu)分析 2)設(shè)計(jì)思路如上圖。3、主要功能與代碼分析1)主要功能該學(xué)生成績管理系統(tǒng)具備兩方面的功能:一方面是學(xué)生用戶,學(xué)生通過輸入學(xué)號和密碼進(jìn)下該系統(tǒng)后,可以進(jìn)行成績查詢,修改密碼等操作;一方面管理員進(jìn)入該系統(tǒng)則比學(xué)生多一些權(quán)限:成績輸入、成績查詢、成績修改、各科

3、成績分布情況、查看學(xué)生信息、刪除學(xué)生信息等。2)代碼分析(自己負(fù)責(zé)的部分)負(fù)責(zé)的部分:管理員登錄、學(xué)生用戶登錄及學(xué)生用戶的功能實(shí)現(xiàn),如查看成績、修改密碼。/*/管理員登陸驗(yàn)證 privatevoid jbutton22actionperformed(java.awt.event.actionevent evt) /獲取輸入信息 string id = jtextfield11.gettext(); string key = jpasswordfield1.gettext(); /賬號輸入錯(cuò)誤標(biāo)記 boolean boolid = true; /創(chuàng)建管理員對象 manager m = new m

4、anager(); /驗(yàn)證信息 if (id.equals(m.getid() boolid = false; if (key.equals(m.getpassword() /登陸成功,顯示管理員功能界面 jframe2.setvisible(false); jframe1.setsize(450, 350); jtextfield11.settext(); jpasswordfield1.settext(); jframe1.setvisible(true); jlabel59.settext(m.getid(); else /密碼錯(cuò)誤,顯示密碼錯(cuò)誤對話框 passworderror.set

5、size(400, 200); passworderror.setvisible(true); jpasswordfield1.settext(); if (boolid) /賬號錯(cuò)誤,顯示賬號錯(cuò)誤對話框 jtextfield11.settext(); jpasswordfield1.settext(); iderror.setsize(400, 200); iderror.setvisible(true); /*/學(xué)生登陸驗(yàn)證 private void jbutton28actionperformed(java.awt.event.actionevent evt) /獲取輸入的學(xué)生驗(yàn)證信息

6、string id = jtextfield13.gettext(); string key = jpasswordfield2.gettext(); /賬號輸入錯(cuò)誤標(biāo)記 boolean boolid = true; /讀取excel文件信息 jxl.workbook readwb = null; try /構(gòu)建workbook對象, 只讀workbook對象 /直接從本地文件創(chuàng)建workbook inputstrea minstream = new fileinputstream(d:/contacteditor/studentlist.xls); readwb = workbook.get

7、workbook(instream); /sheet的下標(biāo)是從0開始 /獲取第一張sheet表 sheet readsheet = readwb.getsheet(0); /獲取sheet表中所包含的總行數(shù) int rsrows = readsheet.getrows(); /獲取指定單元格的對象引用 for (int i = 0; i rsrows; i+) student stu = new student(); cell cell0 = readsheet.getcell(1, i); stu.setid(cell0.getcontents(); cell cell1 = readshe

8、et.getcell(0, i); stu.setpassword(cell1.getcontents(); /驗(yàn)證信息 if (stu.getid().equals(id) boolid = false; if (stu.getpassword().equals(key) /登陸成功,顯示學(xué)生功能界面 studentui1.setvisible(false); studentui2.setsize(400, 400); studentui2.setvisible(true); jtextfield13.settext(); jpasswordfield2.settext(); cell ce

9、ll2 = readsheet.getcell(2, i); stu.setname(cell2.getcontents(); jlabel56.settext(stu.getid(); jlabel57.settext(stu.getname(); else /密碼錯(cuò)誤,顯示密碼錯(cuò)誤提示對話框 jtextfield13.settext(); jpasswordfield2.settext(); passworderror.setsize(400, 200); passworderror.setvisible(true); jpasswordfield2.settext(); /this.se

10、tvisible(true); if (boolid) /賬號錯(cuò)誤,顯示密碼錯(cuò)誤提示對話框 iderror.setsize(400, 200); iderror.setvisible(true); /this.setvisible(true); catch (exception e) finally readwb.close(); /*/學(xué)生用戶查看成績 private void jbutton30actionperformed(java.awt.event.actionevent evt) /查看成績界面 studentui2.setvisible(false); gradelist.set

11、size(500, 400); gradelist.setvisible(true); /定位學(xué)生在excel文件中的位置 string id = jtextfield13.gettext(); string key = jpasswordfield2.gettext(); jxl.workbook readwb = null; try /構(gòu)建workbook對象, 只讀workbook對象 /直接從本地文件創(chuàng)建workbook inputstream instream = new fileinputstream(d:/contacteditor/studentlist.xls); readw

12、b = workbook.getworkbook(instream); /sheet的下標(biāo)是從0開始 /獲取第一張sheet表 sheet readsheet = readwb.getsheet(0); /獲取sheet表中所包含的總行數(shù) int rsrows = readsheet.getrows(); /獲取指定單元格的對象引用 for (int i = 0; i rsrows; i+) student stu = new student(); cell cell0 = readsheet.getcell(1, i); stu.setid(cell0.getcontents(); cell

13、 cell1 = readsheet.getcell(0, i); stu.setpassword(cell1.getcontents(); if (stu.getid().equals(id) if (stu.getpassword().equals(key) /定位成功 cell cell2 = readsheet.getcell(2, i); cell g1 = readsheet.getcell(7, i); cell g2 = readsheet.getcell(8, i); cell g3 = readsheet.getcell(9, i); cell g4 = readsheet

14、.getcell(10, i); stu.setname(cell2.getcontents(); /顯示學(xué)生成績 jlabel54.settext(stu.getid(); jlabel55.settext(stu.getname(); jlabel50.settext(g1.getcontents(); jlabel51.settext(g2.getcontents(); jlabel52.settext(g3.getcontents(); jlabel53.settext(g4.getcontents(); catch (exception e) finally readwb.close

15、(); /*/修改密碼界面顯示 private void jbutton31actionperformed(java.awt.event.actionevent evt) studentui2.setvisible(false); modifypassword.setsize(450, 250); modifypassword.setvisible(true); /-/學(xué)生用戶修改密碼 private void jbutton35actionperformed(java.awt.event.actionevent evt) /獲取輸入的密碼信息 string key = jpasswordfi

16、eld3.gettext(); string newkey = jpasswordfield4.gettext(); string confirmkey = jpasswordfield5.gettext(); /定位學(xué)生位置 int current = 0; /定位成功的當(dāng)前位置 jxl.workbook readwb = null; try inputstream instream = new fileinputstream(d:/contacteditor/studentlist.xls); readwb = workbook.getworkbook(instream); sheet r

17、eadsheet = readwb.getsheet(0); int rscolumns = readsheet.getcolumns(); int rsrows = readsheet.getrows(); for (int i = 0; i rsrows; i+) student stu = new student(); cell cell = readsheet.getcell(0, i); stu.setpassword(cell.getcontents(); /驗(yàn)證信息 if (stu.getpassword().equals(key) current = i; /驗(yàn)證兩次密碼是否一

18、致 if (confirmkey.equals(newkey) /驗(yàn)證通過 /創(chuàng)建新的excel可寫文件 /創(chuàng)建excel工作簿 jxl.write.writableworkbook wwb = workbook.createworkbook(new file(d:/contacteditor/studentlist.xls), readwb); /創(chuàng)建excel工作表 jxl.write.writablesheet ws = wwb.createsheet(test sheet 1, 0); /添加label對象 jxl.write.label b = new jxl.write.label

19、(-1, 0, ); /寫入原有信息 for (int k = 0; k rsrows; k+) for (int j = 0; j rscolumns; j+) cell c = readsheet.getcell(j, k); string a = c.getcontents(); b = new jxl.write.label(j, k, a); ws.addcell(b); /寫入新密碼 b = new jxl.write.label(0, current, newkey); ws.addcell(b); /顯示密碼修改成功提示對話框 jdialog15.setsize(400, 20

20、0); jdialog15.setvisible(true); jpasswordfield3.settext(); jpasswordfield4.settext(); jpasswordfield5.settext(); wwb.write(); wwb.close(); else /顯示兩次密碼輸入不一致提示對話框 jdialog12.setsize(400, 200); jdialog12.setvisible(true); jpasswordfield4.settext(); jpasswordfield5.settext(); break; catch (exception e)

21、finally readwb.close(); /*/管理員類public class manager private final string id = manager; /賬號 private final string password = manager; /密碼 public manager() public string getid() return id; public string getpassword() return password; /*/學(xué)生類public class student private string id; /賬號 private string pass

22、word; /密碼 private string name; /姓名 private char sex; /性別 private string sclass; /班級 private string major; /專業(yè) private string department;/院系 public string getid() return id; public void setid(string id) id = id; public string getpassword() return password; public void setpassword(string password) this.password = password; public string getna

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論