某软件学院软件工程专业《面向对象编程与设计(Java)》期末项目实训大作业——蓝梦教育集团课程选课系统(3)_第1页
某软件学院软件工程专业《面向对象编程与设计(Java)》期末项目实训大作业——蓝梦教育集团课程选课系统(3)_第2页
某软件学院软件工程专业《面向对象编程与设计(Java)》期末项目实训大作业——蓝梦教育集团课程选课系统(3)_第3页
某软件学院软件工程专业《面向对象编程与设计(Java)》期末项目实训大作业——蓝梦教育集团课程选课系统(3)_第4页
某软件学院软件工程专业《面向对象编程与设计(Java)》期末项目实训大作业——蓝梦教育集团课程选课系统(3)_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、杨教授大学堂 精心创作的优秀程序员 职业提升必读系列资料某软件学院软件工程专业面向对象编程与设计(Java)期末项目实训大作业蓝梦教育集团课程选课系统(3)1.1.1 蓝梦教育集团课程选课系统1、任务要求利用在“面向对象编程与设计(Java)”的8周课程所学习到各个方面的知识设计并实现一个C/S架构的J2SE的应用程序(应用Matisse4MyEclipse设计Swing GUI的窗口界面)作为本课程的结课后的项目大作业,该作业的成绩也将作为本课程的结课时的考试成绩(由于本课程是开发类的技术课程,不进行常规的闭卷考试),希望大家加以重视。2、文档介绍 文档中介绍了蓝梦教育集团课程选课系统的功能

2、性需求、非功能性需求以及在开发过程中应遵循的规范,同时也说明了该选课系统的开发环境要求及后期测试与维护流程。3、项目目标 本系统旨在提高教学管理的工作效率,和使选课管理工作规范化、系统化、程序化,避免选课管理的随意性,提高信息处理的速度和准确性,并使得学生能够及时、准确、有效地查询和修改选课情况。4、用户群体(1)蓝梦教育集团学生和老师(2)蓝梦教育集团相关部门人员(3)普通访客5、功能需求 (1)学生登录(帐号和密码假定已经由系统管理人员设定完毕) (2)查询出可选课程的信息 (3)在选课信息窗口内进行选课 (4)退选所选的课程6、界面需求 (1)学生登录窗口内的参考界面其中的“用户名”是学

3、生学号(可以自己规定,或者参考学校的学号规则),登录初始密码也为学号(假定系统管理人员已经分配了帐号和初始密码),身份选择“学生”类型,然后再点击其中的“登录”按钮进行系统身份验证。身份验证成功后,该登录的学生就可进入他的个人选课的信息窗口。(2)学生在选课信息窗口内进行选课 某学生要选他所感兴趣的某门课程,只需要点击相应的课程信息记录前的某个方框(每个可选的课程信息前面都提供有一个方框);选择了某个课程后,然后再点击窗口中的“提交”按钮(在窗口的右下端)提交该选课结果即可。此时将会在“已选课程”的区域中出现所选报的课程名称(如下窗口中的下半部分),表示已经成功地保存了所选的课程,某门课程的选

4、课的过程也就完成了。学生可以继续再重复该过程,继续选择其它所感兴趣的课程。(3)选课之前可以学生先查询出可选课程的信息 在个人选课信息窗口的上方提供有“课程信息查询”界面,可以允许学生查询可选课的状况。(4)退选所选的课程 本系统不仅可以允许学生选课,同时也允许学生将某个不需要的课程删除(也就是退选所选的某门课程)。学生只需要进入选课结果的信息窗口,在“已选课程”中的某个课程信息的右端单击其中的“退选”选项按钮,就可以退选该门课程。(5)课程的主要数据描述 假定有N门课程,每门课程都有课程编号、课程名称、课程性质、总学时、授课学时、实验或上机学时、学分、开课学期、授课教师姓名、上课教室、周课程

5、上课时间等信息。7、相应技术要求 (1)在项目中各个类的设计方面应该遵守面向对象设计中的五大原则,同时在可变化的类的对象实际例化的创建方面应该要应用工厂模式进行解藕。 (2)在项目的功能代码实现方面,应该充分地应用Java技术平台中的多态、Java反射技术及模板模式实现灵活和可重用的功能模块 (3)利用属性配置文件或者XML配置文件来分离项目中的各种工作参数(将各种可配置的工作参数放在配置文件中并在Java类中进行解析)以进一步提高项目的灵活性和可配置性 (4)在技术实现方面应该要考虑安全性(基本的身份验证和访问权限控制)、数据访问的一致性(事务处理)。 (5)选择每个学生自己所熟悉的某种数据

6、库系统,可以为SQLServer2000、Oracl10G、MySQL或者其它数据库系统。并且各自在该数据库中创建出项目中的各个数据库表和表结构(自己根据项目中的数据存储的要求定义出数据库表的结构)。 (6)必须使用数据库连接池的数据库连接方法来连接数据库(不能使用JDBC-ODBC桥方式)。 (7)系统开发工具可以利用Eclipse+MyEclipse工具或者Sun的NetBeans等,大家可以根据自己对某个开发工具的熟悉程度灵活地选用,但推荐大家选用Eclipse+MyEclipse工具。 (8)应用Matisse4MyEclipse设计Swing GUI的窗口、菜单和对话框等界面。8、系

7、统非功能性需求(1)可用性 1)方便操作,操作流程合理 尽量从用户角度出发,以方便使用本产品。2)支持没有计算机使用经验、计算机使用经验较少及有较多计算机使用经验的用户均能方便地使用本系统。3)容错能力 系统具有一定的容错和抗干扰能力,在非硬件故障或非通讯故障时,系统能够保证正常运行,并有足够的提示信息帮助用户有效正确地完成任务。4)联机帮助与操作指南。(2)安全性1)权限控制 根据不同用户角色,设置相应权限,用户的重要操作都做相应的日志记录以备查看,没有权限的用户禁止使用系统。普通用户只可查询选退课,系统管理员可以维护系统。 2)记录日志 本系统应该能够记录系统运行时所发生的所有错误,包括本

8、机错误和网络错误。这些错误记录便于查找错误的原因。日志同时记录用户的关键性操作信息。 3)数据访问的一致性(3)时间特性要求1) 单项数据查询响应时间:1秒2) 对事务的响应时间:平均1秒、最长10秒1.1.2 系统实现结果截图1、系统用户登陆通过:用户名12126055,密码123456 登陆本系统。2、登录成功将进入系统主页面用户可在该页面看到自己可选的课程及已经选择的课程。3、条件查询课程相关信息用户可以通过:查询全部、按课程号查询、按课程名查询、按任课教师查询、按课程性质查询等方式查询课程。4、选课学生选择某一课程,点击选择,系统提示确认选择。点击确认,提示已成功选课点击确定,该课程出

9、现在已选课程的表中,可选课程中去掉该课,该课的课容量减一。5、退选课程学生选择某一课程,点击退选,系统提示确认退选。点击确认,提示已成功退课点击确定,该课出现在可选课程的表中,已选课程中去掉该课,该课的课容量加一。6、退出系统1.1.3 项目系统部分程序代码示例1、LoginFrame程序类import java.awt.BorderLayout;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;imp

10、ort java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import daoImple.StudentManageDaoImple;import entity.Student;public class LoginFrame extends JFram

11、e private JLabel usernameLabel;/用户名private JLabel passwordLabel;/密码private JPasswordField passwordField;/ 密码框private JTextField usernameField;/ 用户名框private JButton resetButton;/重置按钮private JButton loginButton;/登陆按钮private JButton quitButton;/推出按钮public static void main(String args) try LoginFrame fr

12、ame = new LoginFrame();frame.setVisible(true); catch (Exception e) e.printStackTrace();public LoginFrame() / 首先设置窗口的相关信息super();/ 调用父类的构造方法setTitle(学生选课系统);/ 设置窗口的标题setResizable(false);/ 设置窗口不可以改变大小setAlwaysOnTop(true);/ 设置窗口总在最前方setBounds(500, 300, 428, 292);/ 设置窗口的大小setDefaultCloseOperation(JFrame

13、.EXIT_ON_CLOSE);/ 设置当关闭窗口时执行的动作/ 下面将创建一个面板对象并添加到窗口的容器中JPanel panel = new JPanel();panel.setLayout(new GridBagLayout();/ 设置面板的布局管理器为网格组布局getContentPane().add(panel, BorderLayout.CENTER);/ 将面板添加到窗体中/ 下面将创建用户名的标签usernameLabel = new JLabel();usernameLabel.setText(用户名);/usernameLabel.setPreferredSize(new

14、 Dimension(40, 40);/usernameLabel.setSize(100,100);final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();gridBagConstraints_1.insets = new Insets(0,0, 0, 0);/ 设置组件外部上方的填充量为10像素gridBagConstraints_1.gridx = 0;gridBagConstraints_1.gridy = 0;panel.add(usernameLabel, gridBagConstraints

15、_1);panel.add(usernameLabel,gridBagConstraints_1);/创建密码的标签passwordLabel = new JLabel();passwordLabel.setText(密码);final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();gridBagConstraints_2.insets = new Insets(20,0, 0, 0);/ 设置组件外部上方的填充量为10像素gridBagConstraints_2.anchor = GridBagConst

16、raints.EAST;/ 设置为靠左侧显示gridBagConstraints_2.gridx = 0;gridBagConstraints_2.gridy = 1;panel.add(passwordLabel, gridBagConstraints_2);panel.add(passwordLabel,gridBagConstraints_2);/创建用户名文本框usernameField = new JTextField();usernameField.setColumns(20);final GridBagConstraints gridBagConstraints_3 = new

17、GridBagConstraints();gridBagConstraints_3.insets = new Insets(0,20, 0, 0);/ 设置组件外部上方的填充量为10像素gridBagConstraints_3.anchor = GridBagConstraints.WEST;/ 设置为靠左侧显示gridBagConstraints_3.gridx = 1;gridBagConstraints_3.gridy = 0;panel.add(usernameField, gridBagConstraints_3);/创建密码输入框passwordField = new JPassw

18、ordField();passwordField .setColumns(20);final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();gridBagConstraints_4.insets = new Insets( 20,20, 0, 0);/ 设置组件外部上方的填充量为10像素gridBagConstraints_4.anchor = GridBagConstraints.WEST;/ 设置为靠左侧显示gridBagConstraints_4.gridx = 1;gridBagConstraint

19、s_4.gridy = 1;panel.add(passwordField, gridBagConstraints_4);/ 创建并设置一个用来添加三个按钮的面板final JPanel buttonPanel = new JPanel();/ 创建一个用来添加按钮的面板buttonPanel.setLayout(new GridBagLayout();/ 设置面板采用水平箱布局final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();/ 创建网格组布局管理器对象gridBagConstraints_5.i

20、nsets = new Insets(40, 0, 0, 0);/ 设置组件外部上方的填充量为40像素gridBagConstraints_5.gridwidth = 2;/ 设置其占两列gridBagConstraints_5.gridx = 0;/ 设置行索引为3gridBagConstraints_5.gridy = 2;/ 设置列索引为1panel.add(buttonPanel, gridBagConstraints_5);/ 将组件按指定的布局管理器添加到面板中/创建重置按钮resetButton = new JButton();resetButton.setText(重置);fi

21、nal GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();/ 创建网格组布局管理器对象gridBagConstraints_6.insets = new Insets(0, 0, 0, 0);gridBagConstraints_6.gridx = 0;gridBagConstraints_6.gridy = 0;resetButton.addActionListener(new ResetButtonActionListener();buttonPanel.add(resetButton,gridBagCon

22、straints_6);/创建登陆按钮loginButton = new JButton();loginButton.setText(登陆);final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints();/ 创建网格组布局管理器对象gridBagConstraints_7.insets = new Insets(0, 20, 0, 0);gridBagConstraints_7.gridx = 1;gridBagConstraints_7.gridy = 0;loginButton.addActionListe

23、ner(new LoginButtonActionListener();buttonPanel.add(loginButton,gridBagConstraints_7);/创建退出按钮quitButton = new JButton();quitButton.setText(退出);final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();/ 创建网格组布局管理器对象gridBagConstraints_8.insets = new Insets(0, 20, 0, 0);gridBagConstrain

24、ts_8.gridx = 2;gridBagConstraints_8.gridy = 0;quitButton.addActionListener(new QuitButtonActionListener();buttonPanel.add(quitButton,gridBagConstraints_8);/退出按钮相应程序class QuitButtonActionListener implements ActionListener public void actionPerformed(ActionEvent arg0) System.exit(0);/重置按钮相应程序class Res

25、etButtonActionListener implements ActionListener public void actionPerformed(ActionEvent arg0) usernameField.setText();passwordField.setText();/登陆按钮相应程序class LoginButtonActionListener implements ActionListener public void actionPerformed(ActionEvent arg0) Student stu = new Student(usernameField.getT

26、ext(),passwordField.getText();StudentManageDaoImple smdi = new StudentManageDaoImple();if(smdi.UserExist(stu)land(stu);/加载主页面private void land(Student stu)MainFrame mainframe = new MainFrame(stu);mainframe.setVisible(true);this.setVisible(false);2、CourseManageDaoImple程序类import java.sql.Connection;im

27、port java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import dao.CourseManageDaoInterface;import entity.Course;public class CourseManageDaoImple implements CourseManageDaoInterface private MysqlConnectionImple MysqlConnect;/数据库连接类private Co

28、nnection conn;/连接public CourseManageDaoImple() MysqlConnect = new MysqlConnectionImple();Override/按课程号查询public ArrayList selectbyId(String id)PreparedStatement psmt = null;ResultSet rs = null;ArrayList cous=new ArrayList();if(conn = null)conn = MysqlConnect.ConnectToDB();try String sql = select * fr

29、om course where Cou_Id = ?;psmt= conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); catch (SQLException e) e.printStackTrace();try psmt.setString(1, id);rs = psmt.executeQuery(); catch (SQLException e) e.printStackTrace();try while(rs.next()Course cou=new Course()

30、;cou.setId(rs.getString(Cou_Id);cou.setName(rs.getString(Cou_Name);cou.setType(rs.getString(Cou_Type);cou.setTotalhour(rs.getInt(Cou_TotalHour);cou.setClasshour(rs.getInt(Cou_ClassHour);cou.setExphour(rs.getInt(Cou_ExpHour);cou.setWeekhour(rs.getInt(Cou_WeekHour);cou.setCredit(rs.getInt(Cou_Credit);

31、cou.setTerm(rs.getString(Cou_Term);cou.setTeacher(rs.getString(Cou_Teacher);cou.setClassroom(rs.getString(Cou_Classroom);cou.setVolume(rs.getInt(Cou_Volume);cou.setLeftvolume(rs.getInt(Cou_LeftVolume);cous.add(cou); catch (SQLException e) e.printStackTrace();finallyif(rs != null)try rs.close(); catc

32、h (SQLException e) e.printStackTrace();if(psmt != null)try psmt.close(); catch (SQLException e) e.printStackTrace();MysqlConnect.CloseDBConnection();return cous;Override/按课程名查询public ArrayList selectbyName(String name)PreparedStatement psmt = null;ResultSet rs = null;ArrayList cous=new ArrayList();i

33、f(conn = null)conn = MysqlConnect.ConnectToDB();try String sql = select * from course where Cou_Name = ?;psmt= conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); catch (SQLException e) e.printStackTrace();try psmt.setString(1, name);rs = psmt.executeQuery(); catch

34、 (SQLException e) e.printStackTrace();try while(rs.next()Course cou=new Course();cou.setId(rs.getString(Cou_Id);cou.setName(rs.getString(Cou_Name);cou.setType(rs.getString(Cou_Type);cou.setTotalhour(rs.getInt(Cou_TotalHour);cou.setClasshour(rs.getInt(Cou_ClassHour);cou.setExphour(rs.getInt(Cou_ExpHo

35、ur);cou.setWeekhour(rs.getInt(Cou_WeekHour);cou.setCredit(rs.getInt(Cou_Credit);cou.setTerm(rs.getString(Cou_Term);cou.setTeacher(rs.getString(Cou_Teacher);cou.setClassroom(rs.getString(Cou_Classroom);cou.setVolume(rs.getInt(Cou_Volume);cou.setLeftvolume(rs.getInt(Cou_LeftVolume);cous.add(cou); catc

36、h (SQLException e) e.printStackTrace();finallyif(rs != null)try rs.close(); catch (SQLException e) e.printStackTrace();if(psmt != null)try psmt.close(); catch (SQLException e) e.printStackTrace();MysqlConnect.CloseDBConnection();return cous;Override/按教师查询public ArrayList selectbyTeacher(String teach

37、er)PreparedStatement psmt = null;ResultSet rs = null;ArrayList cous=new ArrayList();if(conn = null)conn = MysqlConnect.ConnectToDB();try String sql = select * from course where Cou_Teacher = ?;psmt= conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); catch (SQLExce

38、ption e) e.printStackTrace();try psmt.setString(1, teacher);rs = psmt.executeQuery(); catch (SQLException e) e.printStackTrace();try while(rs.next()Course cou=new Course();cou.setId(rs.getString(Cou_Id);cou.setName(rs.getString(Cou_Name);cou.setType(rs.getString(Cou_Type);cou.setTotalhour(rs.getInt(

39、Cou_TotalHour);cou.setClasshour(rs.getInt(Cou_ClassHour);cou.setExphour(rs.getInt(Cou_ExpHour);cou.setWeekhour(rs.getInt(Cou_WeekHour);cou.setCredit(rs.getInt(Cou_Credit);cou.setTerm(rs.getString(Cou_Term);cou.setTeacher(rs.getString(Cou_Teacher);cou.setClassroom(rs.getString(Cou_Classroom);cou.setV

40、olume(rs.getInt(Cou_Volume);cou.setLeftvolume(rs.getInt(Cou_LeftVolume);cous.add(cou); catch (SQLException e) e.printStackTrace();finallyif(rs != null)try rs.close(); catch (SQLException e) e.printStackTrace();if(psmt != null)try psmt.close(); catch (SQLException e) e.printStackTrace();MysqlConnect.

41、CloseDBConnection();return cous;Override/按课程性质查询public ArrayList selectbyType(String type)PreparedStatement psmt = null;ResultSet rs = null;ArrayList cous=new ArrayList();if(conn = null)conn = MysqlConnect.ConnectToDB();try String sql = select * from course where Cou_Type = ?;psmt= conn.prepareState

42、ment(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); catch (SQLException e) e.printStackTrace();try psmt.setString(1, type);rs = psmt.executeQuery(); catch (SQLException e) e.printStackTrace();try while(rs.next()Course cou=new Course();cou.setId(rs.getString(Cou_Id);cou.setName(rs.g

43、etString(Cou_Name);cou.setType(rs.getString(Cou_Type);cou.setTotalhour(rs.getInt(Cou_TotalHour);cou.setClasshour(rs.getInt(Cou_ClassHour);cou.setExphour(rs.getInt(Cou_ExpHour);cou.setWeekhour(rs.getInt(Cou_WeekHour);cou.setCredit(rs.getInt(Cou_Credit);cou.setTerm(rs.getString(Cou_Term);cou.setTeache

44、r(rs.getString(Cou_Teacher);cou.setClassroom(rs.getString(Cou_Classroom);cou.setVolume(rs.getInt(Cou_Volume);cou.setLeftvolume(rs.getInt(Cou_LeftVolume);cous.add(cou); catch (SQLException e) e.printStackTrace();finallyif(rs != null)try rs.close(); catch (SQLException e) / TODO Auto-generated catch b

45、locke.printStackTrace();if(psmt != null)try psmt.close(); catch (SQLException e) e.printStackTrace();MysqlConnect.CloseDBConnection();return cous;Override/查询所有可选课程public ArrayList selectAll(String id)PreparedStatement psmt = null;ResultSet rs = null;ArrayList cous=new ArrayList();if(conn = null)conn

46、 = MysqlConnect.ConnectToDB();try String sql = select * from course where Cou_Id not in (select Cou_Id from stu_cou where Stu_Id = ?);psmt= conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); catch (SQLException e) e.printStackTrace();try psmt.setString(1, id);rs =

47、 psmt.executeQuery(); catch (SQLException e) e.printStackTrace();try while(rs.next()Course cou=new Course();cou.setId(rs.getString(Cou_Id);cou.setName(rs.getString(Cou_Name);cou.setType(rs.getString(Cou_Type);cou.setTotalhour(rs.getInt(Cou_TotalHour);cou.setClasshour(rs.getInt(Cou_ClassHour);cou.set

48、Exphour(rs.getInt(Cou_ExpHour);cou.setWeekhour(rs.getInt(Cou_WeekHour);cou.setCredit(rs.getInt(Cou_Credit);cou.setTerm(rs.getString(Cou_Term);cou.setTeacher(rs.getString(Cou_Teacher);cou.setClassroom(rs.getString(Cou_Classroom);cou.setVolume(rs.getInt(Cou_Volume);cou.setLeftvolume(rs.getInt(Cou_Left

49、Volume);cous.add(cou); catch (SQLException e) e.printStackTrace();finallyif(rs != null)try rs.close(); catch (SQLException e) e.printStackTrace();if(psmt != null)try psmt.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();MysqlConnect.CloseDBConnection();return cous;Override/增加课余量public boolean addLeft(String id)PreparedStatement psmt = null;ResultSet rs = null;int rowcount = -1;if(conn = null)conn = MysqlConnect.ConnectToDB();try String sql = UPDATE course

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论