zoukankan      html  css  js  c++  java
  • 201571030133/201571030102《小学四则运算练习软件》结对项目报告

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

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

    我的学号:201571030133

    结对伙伴的学号:201571030102

    1、需求分析:

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

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

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

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

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

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

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

    2、 软件设计

     

    3、 核心功能代码展示

     (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 }

    4、程序运行

     

     

     

     

     

     

     

     

     

    5、结对的过程

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

     

    6、结对作业的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

      

    7、汉堡评价法给你的小伙伴一些点评(汉堡评价法:http://www.cnblogs.com/xinz/archive/2011/08/22/2148776.html

           我和结对伙伴,平常在一起的时间比较多,有很好的默契。这个项目是我们第一次合作编程,但由于彼此的熟悉,沟通交流非常愉快,中间我们遇到很多问题,通过一起研究、讨论,基本都有了解决的方法。我们两个的基础都不是很好,需要上网搜索、查书、请教同学的地方比较多,完成的较慢,也存在有些问题的解决处理不是很到位,但实验项目还是可以基本完成,也非常开心。

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

           通过这次结对编程,我认为结对编程可以给我们带来了1+1>2的效果。在以前的编程过程中,由于独立编程,常存在思路比较局限,对问题的发现处理不及时的问题,但在这次的结对编程中,通过与结对伙伴的分析、讨论,扩展了思路,对问题有了新的理解,并可以及时指出彼此的错误进行改正,让我感受到合作的重要性。

     

  • 相关阅读:
    边工作边刷题:70天一遍leetcode: day 3
    边工作边刷题:70天一遍leetcode: day 3
    边工作边刷题:70天一遍leetcode: day 4
    边工作边刷题:70天一遍leetcode: day 4
    边工作边刷题:70天一遍leetcode: day 4
    javascript和jquery 获取触发事件的元素
    javascript 柯里化
    惰性函数
    IE6和IE7的line-height和现代浏览器不一致的问题
    img图片之间有空隙的问题
  • 原文地址:https://www.cnblogs.com/jlh777/p/8711338.html
Copyright © 2011-2022 走看看