详细设计

项目名称:体育场馆预订系统

小组名称:Login团队

项目负责人:程智超

小组成员:彭春阳,田新年,伍骄阳

  1. 1.   引言

1.1编写目的

本部分旨在阐明编写详细设计的目的,面向读者对象。

本文档主要描述各个模块的细节设计,明确系统的结构与实现过程,分析各个模块,描述模块的功能、性能和结构等方面包括模块接口、调用关系、处理过程和算法,以及各个模块的测试方案。本文档的主要读者为软件设计人员、模块开发人员、管理人员、测试人员。

1.2项目背景

1.2.1项目来源

本项目一开始由伍骄阳提出。

1.2.2项目实现

本项目由程智超,彭春阳,田新年,伍骄阳共4人共同实现。

1.3参考资料

[1]窦万峰.软件工程方法与实践[M].北京:机械工业出版社,2009.

1.5版本信息

项目编号

修改日期

修改后版本

修改位置

修改内容概述

1

2018-5-20

1.0

全局

完成系统界面的编写。

 

2

 

2018-6-19

 

2.0

 

全局

实现初步选择一个时间段功能,完善文档。

 

3

 

2018-6-25

 

3.0

 

算法完善

增添实现预定多个时间段功能,完成整个系统设计。

 

  1. 2.   总体设计

2.1需求概述

设置系统初始化:自动创建记录文件和预订表,且初始化为记录表中存入一维数组,数组初始值设为0。

信息比对:用户输入预订项目和时间段,系统进入记录表中进行比对,如果某时段该场地已满,需返回冲突时段帮组用户重新进行预订,预订成功则返回成功信息。

信息存档:比对成功后,如果可以预订,则系统自动将用户预订信息写入预订表中,方便体育场所管理员了解场馆预订信息。

2.2软件结构

 

 

 

  1. 3.   程序描述

3.1模块基本信息

3.1.1系统初始化

主要包括:记录文件和信息表的生成,为记录文件自动填入代表场地的一维数组,为信息表填入表头。如下所示:

 

 

 

3.1.2系统界面

主要包括:运动场所地图与界面设置。

3.1.3读取用户信息

主要包括:设置时间监听器,读取输入。

3.1.4判断输入格式

主要包括:判断用户输入是否符合规范。

3.1.5信息比对

主要包括:判断所选场地项目的有无,所选时段是否有空位。

3.1.6错误弹窗显示

主要包括:接收到错误信息,弹窗显示错误信息。

3.17信息存档

    主要包括:接收正确信息,进行预订信息写入预订表中。

3.2算法

3-2-1 初始化模块调用以下算法完成该功能

模块2-1:

2-1-1 生成记录文件和信息表

2-1-2 自动填入数组和表头

3-2-2 界面设置中调用以下算法完成该功能

模块2-2

2-2-1 界面模块划分

2-2-2 界面布局划分

3-2-3 信息比对中调用以下算法完成该功能

模块2-3

2-3-1 调用对应信息表进行比对

2-3-2 调用错误弹窗进行正确/错误显示

2-3-3 信息存档

3.3算法实现

系统初始化:

//建立记录文件

              fyiyunlanqiu=new File("yiyun/"+dateString+"lanqiu.txt");

              fyiyunzuqiu=new File("yiyun/"+dateString+"zuqiu.txt");

              fyiyunyumaoqiu=new File("yiyun/"+dateString+"yumaoqiu.txt");

              feryunlanqiu=new File("eryun/"+dateString+"lanqiu.txt");

              feryunzuqiu=new File("eryun/"+dateString+"zuqiu.txt");

              feryunwangqiu=new File("eryun/"+dateString+"wangqiu.txt");

              ftiyuguanpingpangqiu=new File("tiyuguan/"+dateString+"pingpangqiu.txt");

              ftiyuguanyumaoqiu=new File("tiyuguan/"+dateString+"yumaoqiu.txt");

              fyiyunyuding=new File("yuding/"+dateString+"yiyunyuding.txt");

              feryunyuding=new File("yuding/"+dateString+"eryunyuding.txt");

              ftiyuguanyuding=new File("yuding/"+dateString+"tiyuguanyuding.txt");

              //如果记录文件不存在,新建记录文件

              if(!fyiyunlanqiu.exists()) {

                     fyiyunlanqiu.createNewFile();

                     write(fyiyunlanqiu,q);

              }

              if(!fyiyunzuqiu.exists()) {

                     fyiyunzuqiu.createNewFile();

                     write(fyiyunzuqiu,q);

              }

              if(!fyiyunyumaoqiu.exists()) {

                     fyiyunyumaoqiu.createNewFile();

                     write(fyiyunyumaoqiu,q);

              }

              if(!feryunlanqiu.exists()) {

                     feryunlanqiu.createNewFile();

                     write(feryunlanqiu,q);

              }

              if(!feryunzuqiu.exists()) {

                     feryunzuqiu.createNewFile();

                     write(feryunzuqiu,q);

              }

              if(!feryunwangqiu.exists()) {

                     feryunwangqiu.createNewFile();

                     write(feryunwangqiu,q);

              }

              if(!ftiyuguanyumaoqiu.exists()) {

                     ftiyuguanyumaoqiu.createNewFile();

                     write(ftiyuguanyumaoqiu,q);

              }

              if(!ftiyuguanpingpangqiu.exists()) {

                     ftiyuguanpingpangqiu.createNewFile();

                     write(ftiyuguanpingpangqiu,q);

              }

              if(!fyiyunyuding.exists()) {

                     fyiyunyuding.createNewFile();

                     chushi(fyiyunyuding);

              }

              if(!feryunyuding.exists()) {

                     feryunyuding.createNewFile();

                     chushi(feryunyuding);

              }

              if(!ftiyuguanyuding.exists()) {

                     ftiyuguanyuding.createNewFile();

                     chushi(ftiyuguanyuding);

              }

             

             

              //初始化记录数组

              yiyunlanqiu=new int[10];

              yiyunzuqiu=new int[10];

              yiyunyumaoqiu=new int[10];

              eryunzuqiu=new int[10];

              eryunlanqiu=new int[10];

              eryunwangqiu=new int[10];

              tiyuguanpingpangqiu=new int[10];

              tiyuguanyumaoqiu=new int[10];

              for(int i=0;i<10;i++)

              {

                             yiyunlanqiu[i]=0;

                             yiyunzuqiu[i]=0;

                             yiyunyumaoqiu[i]=0;

                             eryunzuqiu[i]=0;

                             eryunlanqiu[i]=0;

                             eryunwangqiu[i]=0;

                             tiyuguanpingpangqiu[i]=0;

                             tiyuguanyumaoqiu[i]=0;

              }

//为预定信息表初始写入表头

public static void chushi(File f) {

              try {

                     BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));

                     bw.write("场馆"+"          "+"项目"+"          "+"姓名"+"                                      "+"学号"+"                               "+"手机号"+"                   "+"时间"+"\n");

                     bw.flush();

                     bw.close();

              }catch(Exception e1){

                     e1.printStackTrace();

              }

       }

       //预订信息写入文件中

       public static void write(File f,int e[]){

              try{

                     BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));

                     for(int i=0;i<10;i++) {

                            bw.write(String.valueOf(e[i])+"\n");

                            bw.flush();

                     }

                     bw.close();

              }catch(Exception e1){

                     e1.printStackTrace();

              }

       }

       界面布局算法实现:

       view jf=new view("体育场馆预订系统");

              view.v=jf;

              //读取图片

              img=jf.getToolkit().getImage("ditu.png");

              //设置窗口显示位置和大小

              jf.setBounds(0,0,1580,740);

              //设置窗口大小不可调节

              jf.setResizable(false);

              //禁用布局管理器

              jf.setLayout(null);

             

             

              //添加选择场地的单选按钮

              //新建标签,添加标题

              Label lchangguan=new Label("场馆:");

              //设置标签位置和大小

              lchangguan.setBounds(1160,10,60,80);

              //添加标签到窗口

              jf.add(lchangguan);

              //新建条目组

              CheckboxGroup yundongchang=new CheckboxGroup();

              //新建单选按钮,添加标题,添加到条目组,设置初始状态

              Checkbox yiyun=new Checkbox("一运",yundongchang,true);

              //设置单选按钮位置大小

              yiyun.setBounds(1220, 10, 60, 80);

              //添加单选按钮到窗口

              jf.add(yiyun);

              Checkbox eryun=new Checkbox("二运",yundongchang,false);

              eryun.setBounds(1280, 10, 60, 80);

              jf.add(eryun);

              Checkbox tiyuguan=new Checkbox("体育馆",yundongchang,false);

              tiyuguan.setBounds(1340, 10, 60, 80);

              jf.add(tiyuguan);

             

             

             

              Label lxiangmu=new Label("项目:");

              lxiangmu.setBounds(1160,100,60,80);

              jf.add(lxiangmu);

              CheckboxGroup xiangmu=new CheckboxGroup();

              Checkbox pingpangqiu=new Checkbox("乒乓球",xiangmu,false);

              pingpangqiu.setBounds(1220,100,60,80);

              jf.add(pingpangqiu);

              Checkbox lanqiu=new Checkbox("篮球",xiangmu,true);

              lanqiu.setBounds(1280,100,60,80);

              jf.add(lanqiu);

              Checkbox wangqiu=new Checkbox("网球",xiangmu,false);

              wangqiu.setBounds(1340,100,60,80);

              jf.add(wangqiu);

              Checkbox yumaoqiu=new Checkbox("羽毛球",xiangmu,false);

              yumaoqiu.setBounds(1400,100,60,80);

              jf.add(yumaoqiu);

              Checkbox zuqiu=new Checkbox("足球",xiangmu,false);

              zuqiu.setBounds(1460,100,60,80);

              jf.add(zuqiu);

             

             

             

              Label shijian=new Label("时间:");

              shijian.setBounds(1160, 190,60,80);

              jf.add(shijian);

              //新建复选框,设置标题,设置初始状态

 

             

              Checkbox t8_9=new Checkbox("8~9",false);

              //设置复选框单元位置大小

              t8_9.setBounds(1220, 190, 60, 80);

              //添加复选框单元到窗口

              jf.add(t8_9);

              Checkbox t9_10=new Checkbox("9~10",false);

              t9_10.setBounds(1280, 190, 60, 80);

              jf.add(t9_10);

              Checkbox t10_11=new Checkbox("10~11",false);

              t10_11.setBounds(1340, 190, 60, 80);

              jf.add(t10_11);

              Checkbox t11_12=new Checkbox("11~12",false);

              t11_12.setBounds(1400, 190, 60, 80);

              jf.add(t11_12);

              Checkbox t12_13=new Checkbox("12~13",false);

              t12_13.setBounds(1460, 190, 60, 80);

              jf.add(t12_13);

              Checkbox t13_14=new Checkbox("13~14",false);

              t13_14.setBounds(1220, 280, 60, 80);

              jf.add(t13_14);

              Checkbox t14_15=new Checkbox("14~15",false);

              t14_15.setBounds(1280, 280, 60, 80);

              jf.add(t14_15);

              Checkbox t15_16=new Checkbox("15~16",false);

              t15_16.setBounds(1340, 280, 60, 80);

              jf.add(t15_16);

              Checkbox t16_17=new Checkbox("16~17",false);

              t16_17.setBounds(1400, 280, 60, 80);

              jf.add(t16_17);

              Checkbox t17_18=new Checkbox("17~18",false);

              t17_18.setBounds(1460, 280, 60, 80);

              jf.add(t17_18);

             

             

              Label lxingming=new Label("姓名:");

              lxingming.setBounds(1160,370,60,80);

              jf.add(lxingming);

              //新建文本框设置初始列数

              TextField txingming=new TextField(15);

              //设置文本框位置大小

              txingming.setBounds(1260, 400, 200, 20);

              //添加文本框到窗口

              jf.add(txingming);

             

             

             

              Label lxuehao=new Label("学号:");

              lxuehao.setBounds(1160,460,60,80);

              jf.add(lxuehao);

              TextField txuehao=new TextField(15);

              txuehao.setBounds(1260, 490, 200, 20);

              jf.add(txuehao);

             

             

             

              Label lshoujihao=new Label("手机号:");

              lshoujihao.setBounds(1160,550,60,80);

              jf.add(lshoujihao);

              TextField tshoujihao=new TextField(15);

              tshoujihao.setBounds(1260, 580, 200, 20);

              jf.add(tshoujihao);

             

             

              //新建按钮,设置标题

              JButton jbqueren=new JButton("确认");

              //设置按钮位置大小

              jbqueren.setBounds(1320, 640, 80, 40);

              //设置按钮颜色

              jbqueren.setBackground(Color.LIGHT_GRAY);

              //给按钮添加鼠标监听

信息比对算法实现:

       public static boolean iskong(File f,int j){

              String s="";

              for(int i=0;i<10;i++) {

                     if(q[i]==1) {

                            t[i]++;

                     }

              }

              for(int i=0;i<10;i++) {

                     if(t[i]>j) {

                            s=s+String.valueOf(i+8)+"~"+String.valueOf(i+9)+" ";

                     }

              }

              if(s.length()!=0) {

                     error(v,"以下时间段无法预约:"+s,"预定时间冲突错误");

                     return false;

              }

              else {

                     write(f,t);

                     return true;

              }

       }

       //判断输入输入预订信息的正确性

       public static boolean isRight(){

              if(s1.equals("一运")){

                     if(s2.equals("篮球")){

                            read(fyiyunlanqiu);

                            boolean b=iskong(fyiyunlanqiu,yiyunlanqiu1);

                            if(b==true) {

                                   writetoyuding(fyiyunyuding);

                                   return true;

                            }

                            else {return false;}

                     }

                     if(s2.equals("足球")){

                            read(fyiyunzuqiu);

                            boolean b=iskong(fyiyunzuqiu,yiyunzuqiu1);

                            if(b==true) {

                                   writetoyuding(fyiyunyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("羽毛球")){

                            read(fyiyunyumaoqiu);

                            boolean b=iskong(fyiyunyumaoqiu,yiyunyumaoqiu1);

                            if(b==true) {

                                   writetoyuding(fyiyunyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("网球")){

                            error(v,"抱歉,一运没有网球,请重新预订。","项目选择错误");

                            return false;

                     }

                     if(s2.equals("乒乓球")){

                            error(v,"抱歉,一运没有乒乓球,请重新预订。","项目选择错误");

                            return false;

                     }

              }

              if(s1.equals("二运")){

                     if(s2.equals("篮球")){

                            read(feryunlanqiu);

                            boolean b=iskong(feryunlanqiu,eryunlanqiu1);

                            if(b==true) {

                                   writetoyuding(feryunyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("足球")){

                            read(feryunzuqiu);

                            boolean b=iskong(feryunzuqiu,eryunzuqiu1);

                            if(b==true) {

                                   writetoyuding(feryunyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("网球")){

                            read(feryunwangqiu);

                            boolean b=iskong(feryunwangqiu,eryunwangqiu1);

                            if(b==true) {

                                   writetoyuding(feryunyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("乒乓球")){

                            error(v,"抱歉,二运没有乒乓球,请重新预订。","项目选择错误");

                            return false;

                     }

                     if(s2.equals("羽毛球")){

                            error(v,"抱歉,二运没有羽毛球,请重新预订。","项目选择错误");

                            return false;

                     }

              }

              if(s1.equals("体育馆")){

                     if(s2.equals("乒乓球")){

                            read(ftiyuguanpingpangqiu);

                            boolean b=iskong(ftiyuguanpingpangqiu,tiyuguanpingpangqiu1);

                            if(b==true) {

                                   writetoyuding(ftiyuguanyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("羽毛球")){

                            read(ftiyuguanyumaoqiu);

                            boolean b=iskong(ftiyuguanyumaoqiu,tiyuguanyumaoqiu1);

                            if(b==true) {

                                   writetoyuding(ftiyuguanyuding);

                                   return true;

                            }

                            else {

                                   return false;

                            }

                     }

                     if(s2.equals("篮球")){

                            error(v,"抱歉,体育馆没有篮球,请重新预订。","项目选择错误");

                            return false;

                     }

                     if(s2.equals("足球")){

                            error(v,"抱歉,体育馆没有足球,请重新预订。","项目选择错误");

                            return false;

                     }

                     if(s2.equals("网球")){

                            error(v,"抱歉,体育馆没有网球,请重新预订。","项目选择错误");

                            return false;

                     }

              }

              return false;

       }

       //错误信息弹窗输出,s为错误消息,title为窗口标题

       public static void error(view v,String s,String title) {

              JOptionPane.showMessageDialog(v,s,title,JOptionPane.NO_OPTION);

       }

3.4程序流程

 

3.5测试要点

采用黑盒测试方法,对用户输入,场馆项目超额,信息表记录进行测试。

posted @ 2018-06-28 15:16  V少年如他  阅读(395)  评论(0编辑  收藏  举报