• 201571030102软件工程结对项目


    Github地址链接:https://github.com/J777lh7/201571030133-201571030102

    结对伙伴的博客链接:http://www.cnblogs.com/jlh777/p/8711338.html

    我的学号:201571030102

    结对伙伴的学号:201571030133

    a. 需求分析:

    本次实验采用结对编程方式,设计开发一个小学生四则运算练习软件,使之具有以下功能:

    (1)由计算机从题库文件中随机选择20道加减乘除混合算式,用户输入算式答案,程序检查答案是否正确,每道题正确计5分,错误不计分,20道题测试结束后给出测试总分;

     (2)题库文件可采用实验二的方式自动生成,也可以手工编辑生成,文本格式如下:

     

    (3)程序为用户提供三种进阶四则运算练习功能选择:百以内整数算式(必做)、带括号算式、真分数算式练习;

    (4)程序允许用户进行多轮测试,提供用户多轮测试分数柱状图,示例如下:(未完成)

     

    (5)程序记录用户答题结果,当程序退出再启动的时候,可为用户显示最后一次测试的结果,并询问用户可否进行新一轮的测试;

    (6)测试有计时功能,测试时动态显示用户开始答题后的消耗时间。

    (7)程序人机交互界面是GUI界面(WEB页面、APP页面都可),界面支持中文简体(必做)/中文繁体/英语,用户可以进行语种选择。

    b. 软件设计:使用类图。

     

    c. 核心功能代码展示:展示核心功能代码。

     (1)gui界面代码

      1 package yn;
      2 import java.awt.event.*;
      3 import java.awt.*;
      4 import java.io.BufferedWriter;
      5 import java.io.File;
      6 import java.io.FileWriter;
      7 import java.io.IOException;
      8 import java.util.ArrayList;
      9 
     10 import javax.swing.*;
     11 public class calculate extends JFrame
     12 {
     13     public BinaryTree bTree; 
     14     public static final int DEFAULT_WIDTH = 1000;
     15     public static final int DEFAULT_HEIGHT = 1000;
     16     private JButton button1;
     17     private JButton button2;
     18     private JButton button3;
     19     private JLabel label1;
     20     private JLabel label2;
     21     private JLabel label3;
     22     
     23     private JTextArea textArea1;
     24     private JTextField field;
     25     int cnt=0;
     26     int score=0;
     27     ArrayList<Integer> scores=new ArrayList<Integer>();
     28     public  calculate()
     29     {
     30         setTitle("得分情况");
     31         setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
     32         setLocationByPlatform(true);//可以自行设置窗口位置 
     33         label1 = new JLabel("显示如下:",JLabel.LEFT);
     34         label1.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 18));
     35         label1.setBounds(200, 50, 300,45);
     36         this.add(label1);
     37         
     38         label2 = new JLabel("输入你的答案:",JLabel.LEFT);
     39         label2.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 18));
     40         label2.setBounds(200, 600, 300,45);
     41         this.add(label2);
     42         
     43         label3 = new JLabel("",JLabel.LEFT);
     44         label3.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 18));
     45         label3.setBounds(200, 800, 300,45);
     46         this.add(label3);
     47         
     48         button1 = new JButton("出题");
     49         button1.setBounds(800, 200, 100,25);
     50         this.add(button1);
     51         button2 = new JButton("结果");
     52         button2.setBounds(800, 400, 100,25);
     53         this.add(button2);
     54         button3 = new JButton("总结");
     55         button3.setBounds(800, 600, 100,25);
     56         this.add(button3);
     57         
     58         textArea1 = new JTextArea();
     59         textArea1.setColumns(21);
     60         textArea1.setRows(21);
     61         textArea1.setBounds(200, 100, 400,400);
     62         this.add(textArea1);
     63         
     64         field = new JTextField();
     65         field.setColumns(20);
     66         field.setBounds(400, 600, 300, 45);
     67         this.add(field);
     68         
     69         JPanel pan = new JPanel();
     70         add(pan);
     71         
     72         button1.addActionListener(new ActionListener()
     73         {
     74             public  void actionPerformed(ActionEvent  event)
     75             {         
     76                 if(cnt<20)
     77                 {
     78                     question();
     79                     cnt++;
     80                 }
     81                 else{
     82                     button1.setText("再来一次");
     83                     Start st=new Start();
     84                     st.setVisible(true);
     85                 }
     86                 
     87                           
     88             }
     89          });
     90         
     91         button2.addActionListener(new ActionListener()
     92         {
     93             public  void actionPerformed(ActionEvent  event)
     94             {
     95                 int c=0;
     96                 String n1 = field.getText();
     97                  field.setText(null);
     98                  String result = bTree.CalAndVal();
     99                  textArea1.append(n1);
    100                  
    101                 if(n1.equals(result))
    102                      {
    103                          textArea1.append("  答案正确
    ");          
    104                          score=score+5;     
    105                      }
    106                      else{
    107                          textArea1.append("  答案错误,正确答案为:"+result+"
    ");
    108                      }
    109             }
    110         });    
    111 
    112         button3.addActionListener(new ActionListener()
    113         {
    114             public  void actionPerformed(ActionEvent  event)
    115             {
    116                 scores.add(score);
    117                 //for(int i=0;i<scores.size();i++)                
    118                  label3.setText("你的成绩为:"+scores + "分");
    119                 Chart window=new Chart(scores);
    120                 window.setVisible(true);
    121                 
    122             }
    123         });    
    124         
    125        
    126     }
    127     
    128     public void question()
    129     {
    130         
    131         bTree = new BinaryTree(2);  
    132         bTree.createBTree();  
    133         textArea1.append(bTree.toString() + "=" );
    134     }
    135     
    136 }

     (2)柱状图代码

     1 package yn;
     2 import java.awt.Color;  
     3 import java.awt.Graphics;  
     4 import java.awt.Graphics2D;
     5 import java.util.ArrayList; 
     6   
     7 import javax.swing.JFrame;  
     8   
     9 public class Chart extends JFrame{  
    10   
    11     //绘制柱形统计图  
    12     ArrayList<Integer> ran=new  ArrayList<Integer>();
    13     public Chart(ArrayList<Integer> scores)
    14     {  
    15         super();  
    16         getContentPane().setForeground(Color.CYAN);
    17         setForeground(Color.CYAN);
    18         setBackground(Color.CYAN);
    19         for(int i=0;i<scores.size();i++)
    20         {
    21             ran.add(scores.get(i));
    22             System.out.println(scores.get(i));
    23             
    24             
    25         }
    26           
    27         setTitle("绘制柱形图");  
    28         setSize(600, 400);
    29         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
    30     }  
    31     @Override  
    32     public void paint(Graphics g){
    33         int Width = getWidth();
    34         int Height = getHeight();
    35         int leftMargin = 20;//柱形图左边界
    36         int topMargin = 50;//柱形图上边界
    37         Graphics2D g2 = (Graphics2D) g;
    38         g2.setColor(Color.WHITE);//绘制白色背景
    39         g2.fillRect(0, 0, Width, Height-100);//绘制矩形图
    40         g2.setColor(Color.black);
    41          for(int i=0;i<=10;i++)
    42          {
    43              //绘制灰色横线和百分比
    44              g2.drawString((100-10*i)+"", 15, topMargin+30*i);
    45              g2.drawLine(5, topMargin+30*i, Width, topMargin+30*i);//绘制灰色横线
    46          }
    47          g2.setColor(Color.BLUE);
    48          for(int i=0;i<=ran.size();i++)
    49          {
    50              //绘制柱形图
    51              int step = (i+1)*40;//设置每个柱形图的水平间隔为40
    52              //绘制矩形
    53              g2.fillRoundRect(leftMargin+step*2-5,(100-ran.get(i))*3+50, 40, 300-(100-ran.get(i))*3, 40, 10);
    54              //列出测试轮数
    55              g2.drawString("第"+(i+1)+"轮", leftMargin+step*2, 380);
    56          }    
    57      }  
    58 }

    (3)计时器部分代码

     1 package yn;
     2 
     3 import java.awt.Dimension;
     4 import java.text.SimpleDateFormat;
     5 import java.util.Calendar;
     6 import javax.swing.JFrame;
     7 import javax.swing.JLabel;
     8 import javax.swing.JPanel;
     9 public class TimerThread extends JFrame implements Runnable
    10 {
    11      private JFrame frame;
    12      private JPanel timePanel;
    13      private JLabel timeLabel;
    14      private JLabel displayArea;
    15      private String DEFAULT_TIME_FORMAT = "HH:mm:ss";
    16      private int ONE_SECOND = 1000;
    17      int time = 1;    boolean isRun = true; 
    18      public TimerThread()
    19      {
    20          timePanel = new JPanel();
    21          timeLabel = new JLabel("您本次用时:");
    22          displayArea = new JLabel();
    23          timePanel.add(timeLabel);
    24          timePanel.add(displayArea);
    25          this.add(timePanel);
    26          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    27          this.setBounds(800, 100, 200, 80);
    28      }
    29      public void run()
    30      {
    31          while(isRun)
    32          {    
    33              try {
    34                  displayArea.setText(+time+"s");
    35                  time++;
    36                  Thread.sleep(1000);
    37              } catch (InterruptedException e) {
    38                  e.printStackTrace();
    39              }
    40          }
    41      }
    42 }

    d. 程序运行:程序运行时每个功能界面截图。

    e.描述结对的过程,提供两人在讨论、细化和编程时的结对照片(非摆拍)。

     

    f.提供此次结对作业的PSP。

    PSP2.1

    任务内容

    计划共完成需要的时间(min)

    实际完成需要的时间(min)

    Planning

    计划

    10

    15

    ·       Estimate

    ·  估计这个任务需要多少时间,并规划大致工作步骤

    10

    25

    Development

    开发

    400

    650

    ··       Analysis

      需求分析 (包括学习新技术)

    40

    60

    ·       Design Spec

    ·  生成设计文档

    5

    8

    ·       Design Review

    ·  设计复审 (和同事审核设计文档)

    4

    6

    ·       Coding Standard

      代码规范 (为目前的开发制定合适的规范)

    3

    3

    ·       Design

      具体设计

    120

    200

    ·       Coding

      具体编码

    180

    300

    ·       Code Review

    ·  代码复审

    7

    9

    ·       Test

    ·  测试(自我测试,修改代码,提交修改)

    13

    21

    Reporting

    报告

    15

    24

    ··       Test Report

    ·  测试报告

    10

    20

    ·       Size Measurement

      计算工作量

    2

    1

    ·       Postmortem & Process Improvement Plan

    ·  事后总结 ,并提出过程改进计划

    3

    3

    6  . 

    g. 请使用汉堡评价法给你的小伙伴一些点评。汉堡评价法:http://www.cnblogs.com/xinz/archive/2011/08/22/2148776.html

           平常我们两个相处的时间就很多,各方面也比较相像,但是第一次这么正式的合作还是第一次,过程还是非常愉快的,两个人一起去研究这些内容,去完成实验项目,非常的有成就感。

    h. 结对编程真的能够带来1+1>2的效果吗?通过这次结对编程,请谈谈你的感受和体会。

         这是我第一次尝试在完成此类软件时与同学一起完成,完成软件设计的工程中也遇到了各种各样的问题,一开始的合作过程也因为第一次的实验报告不一样而有不一样的看法,导致程序不知道该选哪一个。经过讨论,我们两个根据上次实验的完成度选定了基本程序,再以源程序为基础在上面更改和加另外的实验要求。完成过程中两个人负责不一样的部分。再完成自己的部分之后再进行整合省了很多时间,而且在设计过程中,两个人可以提出不一样的看法,再择优进行系统的编写,这样也让程序更加完善。两个人的力量也真的大于一个人。

     

     

  • 相关阅读:
    nginx和apache ssl证书的区别
    delphi11.2和谐安装
    微服务网关的实现方法
    dremio 23 版本的试用简单说明
    go workspace 试用
    grafana jpprof jdk 8 支持探索
    dragonfly 兼容redis 以及memcached 的替代工具
    grafana jpprof 试用
    使用 oceanbase做为xxljob 以及nacos 的mysql存储
    dremio parquet zstd 压缩支持docker 镜像
  • 原文地址:https://www.cnblogs.com/yuan1229/p/8716855.html
Copyright © 2020-2023  润新知