结对编程1

结对队友学号:201421123048 201421123036

项目代码:

https://git.coding.net/YJh_/Cal.git


 

题目描述:

我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序。进一步,本次要求把这个程序做成GUI(可以是Windows PC 上的,也可以是Mac、Linux,web,手机上的),成为一个有基本功能、一定价值的程序。在下面的功能需求中实现两个:

  1. 记录用户的对错总数,程序退出再启动的时候,能把以前的对错数量保存并在此基础上增量计算。
  2. 有计时功能,能显示用户开始答题后的消耗时间。
  3. 界面支持中文简体/中文繁体/英语,用户可以选择一种;

 

需求分析:

  1. 在作业一中已经完成了四则运算的分数算法。
  2. 在控制台的输入操作不够人性化,使用GUI界面让用户使用更加方便。
  3. 在用户使用程序做题时需要记录用户做题的对错题数。
  4. 针对不同的用户,需要用到不同的语言,繁体字,简体字,英文版。
  5. 对于能力不同的用户,需要有难易不同程度的题目。
  6. 如果需要测试完成题目所用的时候,需要有记录做题的消耗时间。

 

功能分析:

  • 基本功能
    • GUI界面显示程序
    • 记录做题时间
    • 记录用户做题总数和正确题数
    • 收集用户的错题集并显示给用户
    • 提供简体繁体英文界面
  • 拓展功能
    • 题目难度分为初级中级高级可供用户选择
    • 在各个难度中还有整数和整数型,整数和分数型,分数和分数型

 

程序设计:

用户操作运行流程:

 

主要分类:

Calculator类


 

程序测试

测试截图:

 


 

部分代码展示:

public class LoginMiddle {
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    LoginMiddle window = new LoginMiddle();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    public LoginMiddle() {
        initialize();
    }
    private void initialize() {
        frame = new JFrame();
        frame.setTitle("实战界面中级版两个整数与一个分数型");
        frame.setSize(750,230);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Label L1=new Label("总题数:",Label.RIGHT);
        Label L2=new Label("题目:",Label.RIGHT);
        Label L3=new Label("请输入答案:",Label.RIGHT);
        Label L4=new Label("答题情况:",Label.RIGHT);
        Label L5=new Label("答对题数:",Label.RIGHT);
        Label L6=new Label("答错题数:",Label.RIGHT);
        Label L7=new Label("答题时间:",Label.RIGHT);
        final JButton B1=new JButton("开始");
        final JButton B2=new JButton("下一题");
        final JButton B3=new JButton("退出");
        frame.getContentPane().add(panel,"Center");
        B3.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent arg0) {        
                JOptionPane.showMessageDialog(null, "答题总题数为"+tishu+",答对题数为"+dadui+",答错题数为"+dacuo+",未答题题数为"+noanswer+"。");
                frame.setVisible(false);
                new Middle();
            }            
        });
        B1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                tishu=Integer.parseInt(T1.getText());
                noanswer=tishu-dadui-dacuo;
                summary++;
                timer = new Timer(); 
                finishtime=System.currentTimeMillis();
                starttime=finishtime;
                timer.schedule(new TimerTask() 
                {
                    public void run() {    
                        finishtime=System.currentTimeMillis();
                        duration=finishtime-starttime;
                        if(duration/1000==27&&summary<tishu)
                        {
                            JOptionPane.showMessageDialog(null, "答题时间已到。答题总题数为"+(dadui+dacuo)+",答对题数为"+dadui+",答错题数为"+dacuo+",未答题题数为"+(tishu-dacuo-dadui)+",答题使用时间:"+(allduration+duration)/1000+"秒。");
                            frame.setVisible(false);
                            new Middle();
                        }
                        String str=df.format(new Date(duration)); 
                        T7.setText(str);
                        }  
                    }, 1000, 1000);
                allduration=allduration+duration;
                char a[]={'+','-','×','÷'};
                char b[]={'+','-','×','÷'};
                int c=(int)(Math.random()*4);
                int d=(int)(Math.random()*4);
                int f=(int)(Math.random()*100);
                int g=(int)(Math.random()*99+1);
                int h=(int)(Math.random()*99+1);
                int l=(int)(Math.random()*99+1);
              
      
        Toolkit kit = Toolkit.getDefaultToolkit();        
        Dimension screenSize = kit.getScreenSize();        
        int w1 = screenSize.width;        
        int h = screenSize.height;        
        int x1 = w1/3;        
        int y1 = h/5;    
        frame.setLocation(x1,y1);
        frame.setVisible(true);
        frame.setResizable(false);
    }

 PSP:

PSP2.1 Personal Software Process Stages Time (%) Senior Student(/day) Time (%)(/day)
Planning 计划 8 7
· Estimate 估计这个任务需要多少时间 8 7
Development 开发 6 8
· Analysis 需求分析 (包括学习新技术) 1 1
· Design Spec 生成设计文档 1 1
· Design Review 设计复审 0 0
· Coding Standard 代码规范 1 1
· Design 具体设计 5 4
· Coding 具体编码 2 2
· Code Review 代码复审 1 1
· Test 测试(自我测试,修改代码,提交修改) 3 3
Reporting 报告 1 1
·Test Report 测试报告 1 1
· Size Measurement 计算工作量 1 1
·Postmortem & Process Improvement Plan 并提出过程改进计划 0 0
 

小结感受:

  • 结队编程真的能够带来1+1>2的效果,而且还是女生和我一起结对,俗话说:男女搭配,干活不累。哈哈哈,还真是哦,虽然这个过程很辛苦,整整编写了一周,基础一般般,而且java是大二上的课了,很多都是忘记了,特别是GUI界面的编程,真的忘关了,我还是重新学习了课本,真的有点累!但是还是坚持过来了,想想有个美女在旁边指挥我打代码呢,要好好表现。还真有点效果,界面的设计虽然不好看,能得到美丽的队友的认可还是挺开心的。
  • 由于知识有限,和队友一路走来十分坎坷,导致编写的代码有点拖沓冗余。时间不太够,所以一些自己想拓展的功能还没能得到完成。会继续努力完成的。
  • 对于队友的重要性,有几点要说的。第一,队友帮助我很多,像一些找GUI资料,比较一些标签按钮的操作知识,都是队友帮助我一起完成的。第二就是在打代码打了累的时候,她经常会鼓励我,陪我谈谈心,这让我心情慢慢变得舒畅了很多,不然代码打久了,是挺压抑的。
  • 自己打的代码真的有点烂,以后会继续努力的,经常这次的结对编程,受益匪浅,认识到了自己的不足,对GUI的编程有更一步的了解和认识。

 

合作照片:

 

posted @ 2017-03-15 00:01  _YJc  阅读(182)  评论(1编辑  收藏  举报