java课程设计期末考试题型_java课程设计(班级管理系统)

2021年2月19日发(作者:回家的)

Java

课程设计

p>

学院:船山学院

班级:计算机

姓名:

学号:

2004-12-20

029

------

简单的班级管理系统

一:需求分析

1.

功能需求

1).

能够实现对班级学生基本资料的录入,包括学生的学号,姓名,性别,所学

p>

专业,家庭住址以及出生年月等。

2).

能够实现对学生基本资料的修改。

3).

根据学号对学生资料进行查询。

4).

能够删除某些学生的资料。

二:总体设计

<

br>本班级管理系统共有

6

jav

a

源文件。

类之间的主要关系如下图所示:

StudentManager(

S

tudentSituati

Inque

Delet<

p>

ModiifySituati

Stude

各主类的主要作用如下:

1).

j

ava

文件的类负责创建班级学生管理系统的主窗口。

该类包含

main

方法,

程序从

该类开始执行。

2).

该文件的类负责创建班级学生管理系统的学生信息录入界面。

3).

该文件的类负责创建班级学生

管理系统的学生基本信息修改界面。

4).

该文件的类负责创建班级学生

管理系统的学生基本信息查询界面。

5).

该文件的类负责创建班级学生管理系统的学生信息删除界面。

6).

负责创建存放学生信息的对象。

三:详细设计

1

主类

1).

成员变量

主要成员变量

成员变量描述

基本信息录入界面

基本信息修改界面

基本信息查询界面

基本信息删除界面

菜单选项

存基本信息的散列表

存放散列表的文件

变量类型

StudentSituation

ModifySituation

Inquest

Delete

JMenuItem

Hashtable

File

2).

方法

主要方法

名称

StudentManager

actionPerformed

main

功能

创建程序主窗口

<

br>处理

ActionEvent

事件

程序开始运行

3).

代码

备注

构造方法

接口方法

变量名称

基本信息录入

基本信息修改

基本信息查询

基本信息删除

录入,修改,查询,删除

基本信息

file

import .*;

import

.*;

import .*;

import

class

StudentManager

extends

JFrame

implements

ActionListener

{

StudentSituation

基本信息录入

=null;

ModifySituation

基本信息修改

=null;

Inquest

基本信息查询

=null;

Delete

基本信息删除

=null;

JMenuBar bar;

JMenu fileMenu;

JMenuItem

录入

,

修改

,

查询

,

删除

,

退出

;

Container con=null;

Hashtable

基本信息

=null;

File file=null;

CardLayout card=null;

JLabel label;

JPanel pCenter;

public StudentManager()

{

setTitl

e(

欢迎进入班级管理系统

录入

=new JMenu

Item(

录入学生基本信息

修改

=new JMenu

Item(

修改学生基本信息

查询

=new JMenu

Item(

查询学生基本信息

删除

=new JMenu

Item(

删除学生基本信息

退出

=new

JMenuItem(

退出本系统

退出

.addActionListener(new

ActionListener()

{

public void

actionPerformed(ActionEvent event)

{

(0);

}

});

bar=new JMenuBar();

fileMenu=new

JMenu(

菜单选项

(

录入

);

();

(

修改

);

();

(

查询

);

();

(

删除

);

();

();

(

退出

);

(fileMenu);

setJMenuBar(bar);

label=new JLabel(

欢迎进入班级管理系统

!

(new

Font(

隶书

基本信息

=new

Hashtable();

录入

.addActionListener(this);

修改

.addAction

Listener(this);

查询

.addActionListener(this);

<

br>

删除

.addAc

tionListener(this);

card=new CardLayout();

con=getContentPane();

pCenter=new JPanel();

(card);

file=new

File(

学生基本信息

.txt

if(!())

{

try{

FileOutputStream out=new

FileOutputStream(file);

ObjectOutputStreamobjectOut=new

ObjectOutputStream(out);

(

基本信息

);

();

();

}

catch(IOException e)

{

}

}

基本信息录入

=new

StudentSituation(file);

基本信息修改

=new

ModifySituation(file);

基本信息查询

=new

Inquest(this,file);

基本信息删除

=new

Delete(file);

(

欢迎语界面

(

录入界面

基本信息录入

);

(

修改界面

基本信息修改

);

(

删除界面

基本信息删除

);

(pCenter,;

();

addWindowListener(new WindowAdapter()

{ public void

windowClosing(WindowEvent e)

{

(0);

}

});

setVisible(true);

setBounds(100,50,420,380);

validate();

}

public void

actionPerformed(ActionEvent e)

{

if()==

录入

)

{

(pCenter,

录入界面

}

else if()==

修改

)

{

(pCenter,

修改界面

}

else if()==

查询

)

{

基本信息查询

.setVisible(true);

}

else if()==

删除

)

{

(pCenter,

删除界面

}

}

public static void

main(String args[])

{

new

StudentManager();

}

}

2.

录入界面

1).

成员变量

主要成员变量属性

描述

存放

“学生”对象的散列表

输入学生基本信息的文本

存放学生信息的对象

变量类型

Hashtable

JTextField

Student

变量名称

基本信息表

学号

,

姓名

,

所学专业

,

家庭

住址

,

出生

学生

2).

方法

主要方法

名称

StudentSituation

功能

创建学生信息录入界面

备注

构造方法

actionPerformed

ActionEvent

事件

接口方法

3).

代码

import .*;

import

.*;

import .*;

import .*;

public

class StudentSituation extends JPanel implements

ActionListener

{

Hashtable

基本信息表

=null;

JTextField

学号<

/p>

,

姓名

,

所学专

,

家庭住址

,

出生

;

JRadioButton

,

;

Student

学生

=null;

ButtonGroup group=null;

JButton

录入

,

重置

;

FileInputStream inOne=null;

ObjectInputStream inTwo=null;

FileOutputStream

outOne=null;

ObjectOutputStream outTwo=null;

File file=null;

public

StudentSituation(File file)

{

=file;

学号

=new

JTextField(10);

姓名

=new

JTextField(10);

所学专业

=new

JTextField(10);

家庭住址

=new

JTextField(10);

出生

=new

JTextField(10);

group=new

ButtonGroup();

=new

JRadioButton(

=new

JRadioButton(

(

);

(

);

录入

=new

JButton(

录入

重置

=new

JButton(

重置

录入

.addActionLi

stener(this);

重置

.addActionListener(this);

Box box1=();

(new

JLabel(

学号

:

(

学号

);

Box box2=();

(new JLabel(

姓名

:

(

姓名

);

Box box3=();

(new JLabel(

性别

:

(

);

(

);

Box box4=();

(new JLabel(

所学专业

:

(

所学专业

);

Box box5=();

(new

JLabel(

家庭住址

:

(

家庭住址

);

Box box6=();

(new

JLabel(

出生

:

(

出生

);

Box boxH=();

(box1);

(box2);

(box3);

(box4);

(box5);

(box6);

());

JPanel pCenter=new

JPanel();

(boxH);

setLayout(new

BorderLayout());

add(pCenter,;

JPanel

pSouth=new JPanel();

(

录入

);

(

重置

);

add(pSouth,;

validate();

}

public void

actionPerformed(ActionEvent e)

{

if()==

录入

)

{

String number=

numbe

r=

学号

.getText();

if()>0)

{

try

{

inOne=new FileInputStream(file);

inTwo=new

ObjectInputStream(inOne);

基本信息表

=(Hashtable)();

<

br>

();

();

}

catch(Exception

ee)

{

}

if(

基本信息表

.containsKey(number))

{

String wa

rning=

该生基本信息已存在

,

到修改页面修改

!

(this,warning,

警告

}

else

{

String

m=

基本信息将被录入

!

intok=(this,m,

确认

if(ok==

{

String name=

姓名

.getText();

String discipling=

所学专业

.getText();

String grade=<

p>

家庭住址

.getText();

String borth=<

p>

出生

.getText();

String

sex=null;

if(

.isSelected())

{

sex=

.getText();

}

else

{

sex=

.getText();

}

学生

=new Student();

学生<

p>

.setNumber(number);

学生

.setName(name);

学生<

p>

.setDiscipling(discipling);

学生<

p>

.setGrade(grade);

学生

.setBorth(borth);

学生

.setSex(sex);

try{

outOne=new

FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

本信息表

.put(number,

学生

);

(

基本信息表

);

();

();

学号

.setText(null);

姓名

.setText(null);

所学专业

.setText(null);

家庭住址

.setText(null);

出生

.setText(null);

}

catch(Exception

ee)

{

}

}

}

}

else

{

String

warning=

必须要输入学号

!

(this,warning,

警告

}

}

if()==

重置

)

{

学号

.setText(null);

姓名

.setText(null);

所学专业

.setT

ext(null);

家庭住址

.setText(null);

出生

.setText(null);

}

}

}

3.

查询界面

1).

成员变量

主要成员变量属性

描述

存放“学生”对象的散表

显示学生基本信息的文本

变量类型

Hashtable

JTextField

变量名称

基本信息表

学号

,

姓名

,

所学专业

,

家庭住

,

出生

2).

方法

主要方法

名称

Inquest

actionPerformed

功能

创建查询界面

处理

<

br>ActionEvent

事件

3).

代码

import .*;

import

.*;

import .*;

import .*;

public

class Inquest extends JDialog implements

ActionListener

{

Hashtable

基本信息表

=null;

JTextField

学号<

/p>

,

姓名

,

所学专

,

家庭住址

,

出生

;

JRadioButton

,

;

JButton

查询

;

ButtonGroup group=null;

FileInputStream

inOne=null;

备注

构造方法

接口方法

ObjectInputStream inTwo=null;

File file=null;

public Inquest(JFrame

f,File file)

{

super(f,

查询对话框

=file;

学号

=new

JTextField(10);

查询

=new

JButton(

查询

学号

.addActionLi

stener(this);

查询

.addActionListener(this);

姓名

=new

JTextField(10);

姓名

.setEditable(false);

所学专业

=new

JTextField(10);

所学专业

.setEditable(false);

家庭住址

=new

JTextField(10);

家庭住址

.setEditable(false);

出生

=new

JTextField(10);

出生

.setEditable(false);

=new

JRadioButton(

=new

JRadioButton(

group=new ButtonGroup();

(

);

(

);

Box box1=();

(new

JLabel(

输入要查询的学号

:

(

学号

);

(

查询

);

Box box2=();

(new JLabel(

姓名

:

(

姓名

);

Box box3=();

(new JLabel(

性别

:

(

);

(

);

Box box4=();

(new JLabel(

所学专业

:

(

所学专业

);

Box box5=();

(new

JLabel(

家庭住址

:

(

家庭住址

);

Box box6=();

(new

JLabel(

出生

:

(

出生

);

Box boxH=();

(box1);

(box2);

(box3);

(box4);

(box5);

(box6);

());

JPanel pCenter=new

JPanel();

(boxH);

Container

con=getContentPane();

(pCenter,;

();

setVisible(false);

setBounds(100,200,360,270);

addWindowListener(new WindowAdapter()

{ public void

windowClosing(WindowEvent e)

{

setVisible(false);

}

});

}

public void

actionPerformed(ActionEvent e)

{

姓名

.setText(null);

所学专业

.setText

(null);

家庭住址

.setText(null);

出生

.setText(null);

if()==

查询

||()==

学号

)

{

String number=

numb

er=

学号

.getText();

if()>0)

{

try

{

inOne=new FileInputStream(file);

inTwo=new

ObjectInputStream(inOne);

基本信息表

=(Hashtable)();

<

br>

();

();

}

catch(Exception

ee)

{

}

if(

基本信息表

.containsKey(number))

{

Student

stu=(Student)

基本信息表

.get(numbe

r);

姓名

.setText());

所学专业

.setText());

家庭住址

.setText());

出生

.setText());

if().equals(

{

.setSelected(true);

}

else

{

p>

.setSelected(true);

}

}

else

{

String

warning=

该学号不存在

!

(this,warning,

警告

}

}

else

{

String

warning=

必须要输入学号

!

(this,warning,

警告

}

}

}

}

3.

修改界面

1).

成员变量

主要成员变量

描述

存放“学生”对象的散列表

输入学生基本信息的文本条

变量类型

Hashtabel

JTextField

变量名称

基本信息表

学号

,

姓名

,

所学专业

,

家庭

住址

,

出生

2).

方法

主要方法

名称

ModifySituation

actionPerform

功能

创建学生信息修改界面

处理

ActionEvent

事件

3).

代码

import .*;

备注

构造方法

接口方法

import

.*;

import .*;

import .*;

public

class ModifySituation extends JPanel implements

ActionListener

{

Hashtable

基本信息表

=null;

JTextField

学号<

/p>

,

姓名

,

所学专

,

家庭住址

,

出生

;

JRadioButton

,

;

ButtonGroup group=null;

JButton

开始修改

,

录入修改

,

重置

;

FileInputStream

inOne=null;

ObjectInputStream inTwo=null;

FileOutputStream

outOne=null;

ObjectOutputStream outTwo=null;

File file=null;

public

ModifySituation(File file)

{

=file;

学号

=new

JTextField(10);

姓名

=new JTextField(10);

所学专业

=new

JTextField(10);

家庭住址

=new

JTextField(10);

出生

=new

JTextField(10);

group=new

ButtonGroup();

=new

JRadioButton(

=new

JRadioButton(

(

);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值