java学生成绩管理系统课程设计报告Word下载.docx
- 文档编号:17959145
- 上传时间:2022-12-12
- 格式:DOCX
- 页数:35
- 大小:141.78KB
java学生成绩管理系统课程设计报告Word下载.docx
《java学生成绩管理系统课程设计报告Word下载.docx》由会员分享,可在线阅读,更多相关《java学生成绩管理系统课程设计报告Word下载.docx(35页珍藏版)》请在冰豆网上搜索。
returnnum;
publicvoidsetNum(intnum){
publicintgetYuwen(){
returnyuwen;
publicvoidsetYuwen(intyuwen){
publicintgetShuxue(){
returnshuxue;
publicvoidsetShuxue(intshuxue){
publicintgetJava(){
returnjava;
publicvoidsetJava(intjava){
publicintgetSum(){
returnsum;
publicvoidsetSum(intsum){
this.sum=sum;
publicStringtoString(){
return"
Student[name="
+name+"
num="
+num+"
yuwen="
+yuwen
+"
shuxue="
+shuxue+"
java="
+java+"
sum="
+sum
]"
;
}
②
Student管理类StuC,创建对应方法,实现对Student对象的操作(增、删、改、查询、持久化、成绩排序、成绩统计等功能)供其对象调用。
StuC.java代码
importjava.io.BufferedReader;
importjava.io.File;
importjava.io.FileInputStream;
importjava.io.FileNotFoundException;
importjava.io.FileOutputStream;
importjava.io.FileReader;
importjava.io.IOException;
importjava.io.ObjectInputStream;
importjava.io.ObjectOutputStream;
importjava.util.ArrayList;
publicclassStuC{
ArrayList<
Student>
al=newArrayList<
();
Filefile=newFile("
e:
/mydata.dat"
);
//添加
publicvoidadds(Students){
al.add(s);
//删除
publicvoiddel(intn){
for(inti=0;
i<
al.size();
i++){
if(al.get(i).getNum()==n)
al.remove(i);
}
//求总分
publicvoidsum(){
al.get(i).setSum(al.get(i).getJava()+al.get(i).getShuxue()+al.get(i).getYuwen());
}
//排序
publicvoidsort(){
for(inti=0;
i<
al.size();
i++){
for(intj=0;
j<
al.size()-1-i;
j++){
if(al.get(j).getSum()<
al.get(j+1).getSum()){
Objecto=al.get(j);
al.set(j,al.get(j+1));
al.set(j+1,(Student)o);
}
}
publicvoidpaint(){
System.out.println(al.get(i));
StuC[al="
+al+"
//输出流
publicvoidstor()
{
ObjectOutputStreamout=null;
try{
out=newObjectOutputStream(newFileOutputStream(file));
out.writeObject(al);
out.close();
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
//输入流
publicvoidread()
ObjectInputStreamin=null;
in=newObjectInputStream(newFileInputStream(file));
try{
al=(ArrayList<
)in.readObject();
}catch(ClassNotFoundExceptione){
al=null;
in.close();
Filefile=newFile("
//查找
publicStudentfind(intn)
if(al.get(i).getNum()==n){
returnal.get(i);
returnnull;
}
③
登陆界面及成绩管理的所有界面,同过创建StuC的对象,调用其方法实现成绩管理
代码:
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
publicclassLoginextendsJFrame{
privateTextFieldf1;
privateTextFieldf2;
privateJButtonb1;
privateJButtonb2;
privateJButtonb3;
StuCscs=newStuC();
//登陆界面
publicLogin(){
Containercp=getContentPane();
//容器
cp.setLayout(newGridLayout(3,1));
//三行一列布局
Labell1=newLabel("
用户名"
Labell2=newLabel("
密码"
Panelp1=newPanel();
Panelp2=newPanel();
Panelp3=newPanel();
f1=newTextField(10);
f2=newTextField(10);
f2.setEchoChar('
*'
//回显字符为*
b1=newJButton("
登录"
b2=newJButton("
重置"
b3=newJButton("
退出"
p1.add(l1);
//第一行添加label1
p1.add(f1);
p2.add(l2);
p2.add(f2);
p3.add(b1);
p3.add(b2);
p3.add(b3);
cp.add(p1);
cp.add(p2);
cp.add(p3);
b1.addActionListener(newEnter());
b2.addActionListener(newReWrite());
b3.addActionListener(newClose());
classEnterimplementsActionListener{
publicvoidactionPerformed(ActionEvente)
{
if((f1.getText()).equals("
yazhou"
)&
&
(f2.getText()).equals("
123456"
))
{
scs.read();
//初始化,从文件读入信息
XueShengframe1=newXueSheng();
frame1.setBounds(200,200,300,300);
frame1.setVisible(true);
elseJOptionPane.showMessageDialog(null,"
用户名或密码错误,请重新登录!
"
classReWriteimplementsActionListener{
{
f1.setText("
f2.setText("
f1.requestFocus();
classCloseimplementsActionListener{
JButtonbt=(JButton)e.getSource();
if(bt==b3){
System.exit(0);
//主函数程序开始
publicstaticvoidmain(String[]args){
Loginlog=newLogin();
log.setTitle("
系统登录"
log.setBounds(200,200,300,300);
log.setBackground(Color.blue);
log.setVisible(true);
//信息管理界面内部类进行初始化和保存
classXueShengextendsJFrameimplementsActionListener{
privateJButtoncx,zj,tc,sc,xg,tj;
publicXueSheng()
Containerc=this.getContentPane();
c.setLayout(newGridLayout(3,1));
c.setFont(newFont("
true"
Font.TRUETYPE_FONT,13));
JPanelpanel2=newJPanel();
JPanelpanel1=newJPanel();
JLabellabel1=newJLabel("
欢迎进入成绩管理"
SwingConstants.CENTER);
label1.setFont(newFont("
label1.setForeground(Color.blue);
c.add(label1);
//添加按钮
cx=newJButton("
查询"
panel2.add(cx);
zj=newJButton("
增加"
panel2.add(zj);
sc=newJButton("
删除"
panel2.add(sc);
tc=newJButton("
panel2.add(tc);
xg=newJButton("
修改"
panel1.add(xg);
tj=newJButton("
统计"
panel1.add(tj);
c.add(panel2);
c.add(panel1);
cx.addActionListener(this);
zj.addActionListener(this);
sc.addActionListener(this);
xg.addActionListener(this);
tc.addActionListener(this);
tj.addActionListener(this);
this.setVisible(true);
publicvoidactionPerformed(ActionEvente)
if(e.getSource()==cx){
Findf=newFind();
if(e.getSource()==zj){
AddFIf=newAddFI();
if(e.getSource()==sc){
Deletd=newDelet();
if(e.getSource()==xg){
XiuGaix=newXiuGai();
if(e.getSource()==tc){
shutDown();
if(e.getSource()==tj){
Tongjit=newTongji();
privatevoidshutDown()
scs.stor();
JOptionPane.showMessageDialog(null,"
信息已保存"
this.dispose();
//增加信息界面内部类,捕获文本框中信息创建Student对象,添加到Arraylist中,如果已存在该学号//给出提示信息,并重新添加。
classAddFIextendsJFrameimplementsActionListener{
privateJTextFieldSTNOText,SNAMEText,MAText,CHIText,JAVAText;
privateJButtonb1,b2,b3;
privateStringSTNO,SNAME,MAT,CHI,JAVA;
publicAddFI(){
super("
添加学生信息"
Containerc2=this.getContentPane();
c2.setLayout(newGridLayout(3,1));
JPanelcenter=newJPanel(newGridLayout(5,2));
JPanellow=newJPanel(newFlowLayout());
SwingConstants.CENTER);
TRUE"
Font.TRUETYPE_FONT,20));
c2.add(label1);
STNOText=newJTextField(30);
//30列文本框
SNAMEText=newJTextField(30);
CHIText=newJTextField(30);
MAText=newJTextField(30);
JAVAText=newJTextField(30);
center.add(newJLabel("
学号"
SwingConstants.CENTER));
//添加标签学号写在标签中间
center.add(STNOText);
//添加文本框
姓名"
center.add(SNAMEText);
语文"
center.add(CHIText);
数学"
center.add(MAText);
java"
center.add(JAVAText);
c2.add(center);
b1=newJButton("
添加"
b2=newJButton("
清除"
b3=newJButton("
low.add(b1);
low.add(b2);
low.add(b3);
c2.add(low);
//添加监听
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
this.setBounds(200,200,600,400);
this.setTitle("
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==b1){
try{
addFI();
}catch(FileNotFoundExceptione1){
e1.printStackTrace();
}catch(IOExceptione1){
if(e.getSource()==b2){
clearForm();
if(e.getSource()==b3){
this.dispose();
privatevoidaddFI()throwsFileNotFoundException,IOException{
STNO=STNOText.getText();
SNAME=SNAMEText.getText();
CHI=CHIText.getText();
MAT=MAText.getText();
JAVA=JAVAText.getText();
if(STNO.length()==0||SNAME.length()==0||MAT.length()==0
||JAVA.length()==0||CHI.length()==0)
JOptionPane.showMessageDialog(this,"
请添加完全信息"
else{
Studenta=newStudent(SNA
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 学生 成绩管理系统 课程设计 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)