java学生成绩管理系统课程Word文件下载.docx

上传人:b****5 文档编号:21475969 上传时间:2023-01-30 格式:DOCX 页数:36 大小:143.82KB
下载 相关 举报
java学生成绩管理系统课程Word文件下载.docx_第1页
第1页 / 共36页
java学生成绩管理系统课程Word文件下载.docx_第2页
第2页 / 共36页
java学生成绩管理系统课程Word文件下载.docx_第3页
第3页 / 共36页
java学生成绩管理系统课程Word文件下载.docx_第4页
第4页 / 共36页
java学生成绩管理系统课程Word文件下载.docx_第5页
第5页 / 共36页
点击查看更多>>
下载资源
资源描述

java学生成绩管理系统课程Word文件下载.docx

《java学生成绩管理系统课程Word文件下载.docx》由会员分享,可在线阅读,更多相关《java学生成绩管理系统课程Word文件下载.docx(36页珍藏版)》请在冰豆网上搜索。

java学生成绩管理系统课程Word文件下载.docx

this.yuwen=yuwen;

this.shuxue=shuxue;

this.java=java;

publicStringgetName(){

returnname;

publicvoidsetName(Stringname){

publicintgetNum(){

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.showM

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1