天天看點

綜合例題:學生管理系統

使用面向對象的程式設計方式編寫一個學生管理系統:

   分析一下業務,這個系統将具有什麼功能。例如:1.學生入學,2.查詢學生,3報表統計,4.退出系統。

然後就可以先寫出一個界面,提供以上選項:

<a href="https://s5.51cto.com/oss/201710/19/f0528af89d02e29ee3ac794164516ab2.png" target="_blank"></a>

 既然是管理系統那存儲的就是學生的資料,學生的資料便是學生的各種屬性,是以分析學生具有的屬性有哪些,例如:名字,年齡,性别,位址,郵箱等等。

 自然接下來就先寫一個學生的屬性封裝類将屬性都先封裝起來:

<a href="https://s2.51cto.com/oss/201710/19/079f3c65eae50be0a28c73c6905c6229.png" target="_blank"></a>

 封裝好學生的屬性後,就可以開始編寫這個管理系統的每一個功能塊的封裝了,寫功能要一個一個來寫,是以先完成學生入學的功能編寫。例如:

<a href="https://s3.51cto.com/oss/201710/19/87f12e617eca85ae220d48078f225513.png" target="_blank"></a>

使用Student類型來申請一個數組,是因為記錄存儲每一個入學的學生對象。然後申請一個int變量來制定一個起始的學号,這樣每個學生對象都會有自己的獨一無二的編号(學号)。

然後開始編寫第一個功能塊,學生入學:

<a href="https://s4.51cto.com/oss/201710/19/477cb10e7507508e8df8d32968aa8f9c.png" target="_blank"></a>

接着就是第二個功能塊,查詢學生(含有修改學生、删除學生功能)。查詢學生:

<a href="https://s3.51cto.com/oss/201710/19/00d619cc7907049084a4046a60d4f000.png" target="_blank"></a>

删除學生:

<a href="https://s2.51cto.com/oss/201710/19/b90258ab281c36195e409f7ec1f2b47b.png" target="_blank"></a>

修改學生資料:

<a href="https://s2.51cto.com/oss/201710/19/01881986d5b1caa6c69153bbd42b91b9.png" target="_blank"></a>

 查詢學生這個功能塊就實作了,接下來就是報表統計功能了。先寫一個報表統計的封裝類,将屬性封裝好來:

<a href="https://s5.51cto.com/oss/201710/19/c6401741b0d5b877761076a62c16037e.png" target="_blank"></a>

接着在系統封裝類裡實作報表統計這個功能:

<a href="https://s3.51cto.com/oss/201710/19/a3f77bfe4ee3ca66818c73ab07f00d48.png" target="_blank"></a>

 現在所有的功能塊都在系統功能封裝類裡實作完了,接着就是将這些功能在界面類裡将它們串在一起進行管理系統的實作了,首先将學生入學功能的界面進行編寫:

<a href="https://s1.51cto.com/oss/201710/19/3a9210fc957389841c4db8cf2180a937.png" target="_blank"></a>

學生查詢:

<a href="https://s3.51cto.com/oss/201710/19/49c1b5f388675ea1f79d96aa69d77dc0.png" target="_blank"></a>

删除學生資料:

<a href="https://s2.51cto.com/oss/201710/19/5f68f15e709862bd3d8b5a8078d8d5d6.png" target="_blank"></a>

<a href="https://s3.51cto.com/oss/201710/19/2d73834561a8498e12051eb2bbb6c409.png" target="_blank"></a>

<a href="https://s4.51cto.com/oss/201710/19/a560a13394272e311742684731da08f9.png" target="_blank"></a>

報表統計:

<a href="https://s5.51cto.com/oss/201710/19/6756c8062e86e25ac45426ccef72008f.png" target="_blank"></a>

<a href="https://s5.51cto.com/oss/201710/19/d4bff9322a1eb8fd3513709cfafe1526.png" target="_blank"></a>

完成效果:

  主界面:

<a href="https://s4.51cto.com/oss/201710/19/7ec5ae16aa62fe44660e4f05e1d44122.png" target="_blank"></a>

學生入學:

<a href="https://s3.51cto.com/oss/201710/19/5a58454811bde699f4371c76dbaf5fd4.png" target="_blank"></a>

查詢學生:

<a href="https://s2.51cto.com/oss/201710/19/c804b92c10c98694a789aa234c7bb68c.png" target="_blank"></a>

<a href="https://s3.51cto.com/oss/201710/19/38ff00e3acf45d71a8f8d30f4cb9a18d.png" target="_blank"></a>

<a href="https://s5.51cto.com/oss/201710/19/10582b7797fd08cdf06d153646e0a1cb.png" target="_blank"></a>

<a href="https://s3.51cto.com/oss/201710/19/a536c0bf08e1014cd9fa748d770355aa.png" target="_blank"></a>

<a href="https://s2.51cto.com/oss/201710/19/409cdc7a8a5963c042c11be3b74b15c3.png" target="_blank"></a>

<a href="https://s3.51cto.com/oss/201710/19/e69a30e07f15a38507aec4ae29eb03a0.png" target="_blank"></a>

<a href="https://s4.51cto.com/oss/201710/19/f446755b3f18c8e08abfcf063c3295a8.png" target="_blank"></a>

至此整個學生管理系統就完成了!

<b>本文轉自 ZeroOne01 51CTO部落格,原文連結:http://blog.51cto.com/zero01/1974355,如需轉載請自行聯系原作者</b>