学生成绩管理系统(一)

        这是以前学Java时的一个作业,这里再重新修改一下需求,从头来一遍做一个简单地例子,希望对其他同学有帮助。

1 基本需求  

        设计一个学生成绩管理系统,实现学生登录和管理员登录:

学生登录

  • 查看个人信息,并修改
  • 查看个人成绩

管理员登录

  • 增添、删除、修改学生基本信息(基本信息包含学生的学号、姓名、专业分数等信息);
  • 计算每门课的平均成绩;
  • 统计优秀、良好、中等、及格、不及格的人数百分比,并以柱状图、饼图呈现【说明:可以使用SWINGAWT自己绘制;也可以使用开源类库,如JFreeChart
  • 按学号查询学生及成绩;
  • 按照成绩分数排序。

总体上,这个例子,使用MySQL作为数据库,使用SWing做一个简单地界面,JFreeChart做一些图,当然用Eclipse开发。

2 数据库设计

简单地设计了几个数据库表,使用MySQL5.5数据库

 


图1 数据库设计

 也不知道这数据库设计的对不对,下面是建表语句:(有一个外键一直加不上,不知道什么原因,以后再修改。)

-- ----------------------------
-- Table structure for `t_administrator`
-- ----------------------------
DROP TABLE IF EXISTS `t_administrator`;
CREATE TABLE `t_administrator` (
  `name` varchar(10) NOT NULL,
  `password` varchar(20) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_administrator
-- ----------------------------

-- ----------------------------
-- Table structure for `t_course`
-- ----------------------------
DROP TABLE IF EXISTS `t_course`;
CREATE TABLE `t_course` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_course
-- ----------------------------

-- ----------------------------
-- Table structure for `t_middle_course_stuClass`
-- ----------------------------
DROP TABLE IF EXISTS `t_middle_course_stuClass`;
CREATE TABLE `t_middle_course_stuClass` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `stuClassId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_course_middle` (`courseId`),
  CONSTRAINT `FK_course_middle` FOREIGN KEY (`courseId`) REFERENCES `t_course` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_middle_course_stuClass
-- ----------------------------

-- ----------------------------
-- Table structure for `t_score`
-- ----------------------------
DROP TABLE IF EXISTS `t_score`;
CREATE TABLE `t_score` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `studentId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  `score` double NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_score_course` (`courseId`),
  KEY `FK_score_student` (`studentId`),
  CONSTRAINT `FK_score_course` FOREIGN KEY (`courseId`) REFERENCES `t_course` (`id`),
  CONSTRAINT `FK_score_student` FOREIGN KEY (`studentId`) REFERENCES `t_student` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_score
-- ----------------------------

-- ----------------------------
-- Table structure for `t_stuClass`
-- ----------------------------
DROP TABLE IF EXISTS `t_stuClass`;
CREATE TABLE `t_stuClass` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_stuClass
-- ----------------------------

-- ----------------------------
-- Table structure for `t_student`
-- ----------------------------
DROP TABLE IF EXISTS `t_student`;
CREATE TABLE `t_student` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(10) NOT NULL,
  `password` varchar(15) NOT NULL,
  `gender` tinyint(4) DEFAULT NULL,
  `stuClassId` int(11) NOT NULL,
  `birthday` date DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `personalWord` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


 

 3 代码实现

从这里开始,直接编写代码,不做更加详细的设计.

3.1 实体类的编写

为了方便,这里都设置了一个自动增长的ID作为唯一标识

package org.ygy.model;

/**
 * 学生类
 * 
 * @author Administrator
 *
 */
public class Student {
	private int id;				//唯一标识
	private String name;			//姓名
	private String password;		//密码
	private boolean gender;			//性别
	private String birthday;		//生日
	private int age;			//年龄
	private String personalWord;	        //个性签名
	private StudentClass studentClass;	//所在班级

	//省略getter和setter方法

}

package org.ygy.model;

import java.util.HashSet;
import java.util.Set;

/**
 * 班级类
 * 
 * @author Administrator
 * 
 */
public class StudentClass {
	private int id;			//唯一标识ID
	private String name;	        //班级名称
	private Set<Course> courses = new HashSet<Course>();//班级所选的课程

        //省略getter和setter方法

}

package org.ygy.model;

/**
 * 课程类
 * 
 * @author Administrator
 *
 */
public class Course {
	private int id;			//唯一标识ID
	private String name;		//课程名称

       //省略getter和setter方法

}

 

package org.ygy.model;

/**
 * 成绩类
 * 
 * @author Administrator
 *
 */
public class Score {
        private int id;      //唯一标识ID
        private Student student;       //学生
        private Course course;        //课程
        private double score;        //分数

      //省略getter和setter方法

}

 
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值