• 201571030301/201571030302《小学生四则运算练习软件》结对项目报告


    一丶需求分析

    •      本次实验采用结对编程方式,设计开发一个小学生四则运算练习软件,使之具有以下功能:
    •      由计算机从题库文件中随机选择20道加减乘除混合算式,用户输入算式答案,程序检查答案是否正确,每道题正确计5分,错误不计分,20道题测试结束后给出测试总分;
    •      题库自动生成;
    •      程序为用户提供三种进阶四则运算练习功能选择:百以内整数算式(必做)、带括号算式、真分数算式练习;
    •      程序允许用户进行多轮测试,提供用户多轮测试分数柱状图,示例如下:
    •      程序记录用户答题结果,当程序退出再启动的时候,可为用户显示最后一次测试的结果,并询问用户可否进行新一轮的测试;
    •      测试有计时功能,测试时动态显示用户开始答题后的消耗时间。
    •      程序人机交互界面是GUI界面(WEB页面、APP页面都可),界面支持中文简体(必做)/中文繁体/英语,用户可以进行语种选择。

    二丶软件设计:使用类图

    三丶核心功能代码

     1 import java.util.ArrayList;
     2 
     3 public class SetAQuestion {
     4     int n;
     5     int next,time;
     6     String topic;
     7     GetRandomDigit grd=null;
     8     ArrayList<Topic> al;
     9     Topic question;
    10     ArithmeticResult ar;
    11     public void setAQuestion(int n){
    12         this.n=n;
    13         init();
    14         setQuestion();
    15     }
    16     
    17     
    18     public void init(){
    19         grd=new GetRandomDigit();
    20         al=new ArrayList<Topic>();
    21         ar=new ArithmeticResult();
    22     }
    23     
    24     public ArrayList<Topic> getQuestion(){
    25         return al;
    26     }
    27     
    28     public void setQuestion(){
    29         //出题的数量
    30         int[] questionTopic;;
    31         int[] questionOprator;
    32         for(int i=0;i<n;i++){
    33             //出题的长度
    34             time=grd.Time();
    35             questionTopic=new int[time];
    36             questionOprator=new int[time-1];
    37             for(int t=0;t<time;t++){
    38                 questionTopic[t]=grd.randomDigit();
    39                 if(t<time-1){
    40                     questionOprator[t]=grd.oprator();
    41                 }
    42             }
    43             topic="";
    44             int bracketsIndex=-1;
    45             if(PQ()){
    46                 bracketsIndex=grd.BracketsIndex(time);
    47             }
    48             for(int t=0;t<time;t++){
    49                 if(bracketsIndex==t){
    50                     topic=topic+"(";
    51                 }
    52                 
    53                 topic=topic+questionTopic[t];
    54                 if(bracketsIndex+1==t && bracketsIndex!=-1){
    55                     topic=topic+")";
    56                 }
    57                 if(t<time-1){
    58                     topic=topic+getType(questionOprator[t]);
    59                 }
    60             }
    61             topic=topic+"=";
    62             double a=ar.Result(topic);
    63             if(a<0||a%1!=0||a>500){
    64                 i--;
    65                 continue;
    66             }
    67             question=new Topic(topic,(int)a);
    68             al.add(question);
    69         }
    70     }
    71     
    72     String getType(int type){
    73         if(type==1){
    74             return "+";
    75         }else if(type==2){
    76             return "-";
    77         }else if(type==3){
    78             return "×";
    79         }else{
    80             return "÷";
    81         }
    82     }
    83     
    84     boolean PQ(){
    85         int PQ=grd.probabilityQuestion();
    86         if(PQ<=120){
    87             return true;
    88         }else{
    89             return false;
    90         }
    91     }
    92 }
    出题
      1 import java.awt.GridLayout;
      2 import java.awt.event.ActionEvent;
      3 import java.awt.event.ActionListener;
      4 
      5 import javax.swing.JButton;
      6 import javax.swing.JFrame;
      7 import javax.swing.JLabel;
      8 import javax.swing.JPanel;
      9 import javax.swing.JTextField;
     10 
     11 @SuppressWarnings("serial")
     12 public class MyPanel extends JFrame{
     13     JLabel name,pass,kong;
     14     JTextField nameText,passText;
     15     JPanel jp1,jp2;
     16     JButton ok,quit;
     17     public MyPanel(){
     18         init();
     19         addAction();
     20         this.setTitle("欢迎登陆");
     21         this.setSize(600,200);
     22         this.setLocationRelativeTo(null);
     23         this.setVisible(true);
     24         this.setResizable(false);
     25         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     26         this.setLayout(new GridLayout(2,1));
     27         
     28     }
     29     
     30     private void init(){
     31         name=new JLabel("姓名");
     32         pass=new JLabel("密码");
     33         kong=new JLabel("     ");
     34         nameText=new JTextField(20);
     35         passText=new JTextField(20);
     36         jp1=new JPanel();
     37         jp2=new JPanel();
     38         ok=new JButton("登陆");
     39         quit=new JButton("退出");
     40         addFrame();
     41     }
     42     
     43     private void hideFrame(){
     44         this.setVisible(false);
     45     }
     46     
     47     private void addFrame(){
     48         jp1.add(name);
     49         jp1.add(nameText);
     50         jp1.add(kong);
     51         jp1.add(pass);
     52         jp1.add(passText);
     53         jp2.add(ok);
     54         jp2.add(quit);
     55         this.add(jp1);
     56         this.add(jp2);
     57     }
     58     
     59     private void addAction(){
     60         quit.addActionListener(new ActionListener() {
     61             
     62             @Override
     63             public void actionPerformed(ActionEvent e) {
     64                 // TODO Auto-generated method stub
     65                 System.exit(0);
     66             }
     67         });
     68         ok.addActionListener(new ActionListener() {
     69             
     70             @Override
     71             public void actionPerformed(ActionEvent e) {
     72                 // TODO Auto-generated method stub
     73                 String name=nameText.getText().toString();
     74                 String pass=passText.getText().toString();
     75                 if(name.equals("admin")&&pass.equals("admin")){
     76                     hideFrame();
     77                     new QuestionPanel();
     78                 }
     79             }
     80         });
     81     }
     82 }
     83 
     84 
     85 
     86 
     87 
     88 import java.awt.BorderLayout;
     89 import java.awt.FlowLayout;
     90 import java.awt.GridLayout;
     91 import java.awt.event.ActionEvent;
     92 import java.awt.event.ActionListener;
     93 import java.util.ArrayList;
     94 
     95 import javax.swing.JButton;
     96 import javax.swing.JFrame;
     97 import javax.swing.JLabel;
     98 import javax.swing.JPanel;
     99 import javax.swing.JTextField;
    100 @SuppressWarnings("serial")
    101 public class QuestionPanel extends JFrame{
    102     JPanel jp1,jp2,jp3;
    103     JButton ok,endQuestion;
    104     JLabel timesLabel;
    105     JTextField times;
    106     JPanel[] question;
    107     JLabel[] questionLabel;
    108     JTextField[] questionText;
    109     SetAQuestion saq;
    110     ArrayList<Topic> al;
    111     public QuestionPanel(){
    112         init();
    113         addPanel();
    114         addAction();
    115         this.setTitle("欢迎使用四则运算答题界面");
    116         this.setSize(860,350);
    117         this.setLocationRelativeTo(null);
    118         this.setVisible(true);
    119         this.setResizable(false);
    120         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    121         this.setLayout(new BorderLayout());
    122     }
    123     
    124     private void addPanel(){
    125         for(int i=0;i<25;i++){
    126             question[i].add(questionLabel[i]);
    127             question[i].add(questionText[i]);
    128             jp2.add(question[i]);
    129         }
    130         jp1.add(timesLabel);
    131         jp1.add(times);
    132         jp1.add(ok);
    133         jp3.add(endQuestion);
    134         this.add(jp1,BorderLayout.NORTH);
    135         this.add(jp2, BorderLayout.CENTER);
    136         this.add(jp3, BorderLayout.SOUTH);
    137     }
    138     
    139     private void init(){
    140         jp1=new JPanel();
    141         jp2=new JPanel();
    142         jp3=new JPanel();
    143         saq=new SetAQuestion();
    144         ok=new JButton("开始答题");
    145         timesLabel=new JLabel("答对题目数量");
    146         endQuestion=new JButton("提交");
    147         endQuestion.setEnabled(false);
    148         times=new JTextField(6);
    149         times.setEnabled(false);
    150         jp2.setLayout(new GridLayout(5, 5));
    151         question=new JPanel[25];
    152         questionLabel=new JLabel[25];
    153         questionText=new JTextField[25];
    154         for(int i=0;i<25;i++){
    155             question[i]=new JPanel();
    156             question[i].setLayout(new FlowLayout(FlowLayout.RIGHT));
    157             questionLabel[i]=new JLabel("? * ? = ");
    158             questionText[i]=new JTextField(4);
    159         }
    160     }
    161     private void addAction(){
    162         ok.addActionListener(new ActionListener() {
    163             
    164             @Override
    165             public void actionPerformed(ActionEvent e) {
    166                 // TODO Auto-generated method stub
    167                 saq.setAQuestion(25);
    168                 al=saq.getQuestion();
    169                 for(int i=0;i<25;i++){
    170                     questionLabel[i].setText(al.get(i).getTopic());
    171                     questionText[i].setText("");
    172                 }
    173                 ok.setEnabled(false);
    174                 endQuestion.setEnabled(true);
    175             }
    176         });
    177         endQuestion.addActionListener(new ActionListener() {
    178             
    179             @Override
    180             public void actionPerformed(ActionEvent e) {
    181                 // TODO Auto-generated method stub
    182                 int result=0;
    183                 for(int i=0;i<25;i++){
    184                     int questionResult=Integer.parseInt(questionText[i].getText());
    185                     if(questionResult==al.get(i).getResult()){
    186                         result++;
    187                     }
    188                 }
    189                 times.setText(String.valueOf(result));
    190                 
    191                 endQuestion.setEnabled(false);
    192                 ok.setEnabled(true);
    193                 ok.setText("再来一次");
    194             }
    195             
    196         });
    197     }
    198 }
    界面

    四丶程序运行

    1.登陆页面

    2.点击开始答题进行答题

    3.点击再来一次重新答题

    .

    五丶结对过程

    六丶PSP

    PSP2.1

    任务内容

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

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

    Planning

    计划

    30

    20

    ·       Estimate

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

    30

    20

    Development

    开发

    1200

    1100

    ··       Analysis

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

    50

    50

    ·       Design Spec

    ·  生成设计文档

    50

    50

    ·       Design Review

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

    100

    100

    ·       Coding Standard

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

    50

    50

    ·       Design

      具体设计

    200

    100

    ·       Coding

      具体编码

    500

    600

    ·       Code Review

    ·  代码复审

    50

    50

    ·       Test

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

    200

    100

    Reporting

    报告

    44

    30

    ··       Test Report

    ·  测试报告

    14

    2

    ·       Size Measurement

      计算工作量

    10

    8

    ·       Postmortem & Process Improvement Plan

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

    20

    20

    七丶汉堡评价

       我和我的小伙伴是一个宿舍的,我们平时也是很好的朋友,我俩的编程水平都很一般。这次我俩共同合作,又在好朋友的帮助下顺利完成了这次实验内容。从需求分析到PSP,我们共同提出意见,互相采纳各自的优点内容。他虽然编程水平不高,但他是一个非常有想法的人,包括对实验整体框架有独特的想法。这次的结对实验,很有趣,我们可以发现各自的优缺点,取长补短。非常希望之后还会有这类的合作项目。

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

        1+1>2的效果这次很深刻地体现出来了,结对编程真的能够带来1+1>2的效果!之前一个人做的时候很迷茫,有很多不会的地方。这次有了合作伙伴,我俩各有自己的意见,互相采纳,互相帮助。有一些不会的地方通过我们一起讨论顺利的解决了。总之,结对编程可以提高我们的团队意识,提高了完成任务的效率。

  • 相关阅读:
    P2986 [USACO10MAR] Great Cow Gathering G
    L3025 那就别担心了 (天梯赛)
    P7960 [NOIP2021] 报数
    #10121. 「一本通 4.2 例 3」与众不同
    2016第七届蓝桥杯大赛个人赛省赛(软件类)真题 C大学A组
    L33 胜利者集合(天梯赛)
    士兵过河
    P1899 魔法物品
    状压dp专题
    P3177 [HAOI2015] 树上染色
  • 原文地址:https://www.cnblogs.com/ahmatjan/p/8718714.html
Copyright © 2020-2023  润新知