• 结对编程-四则运算生成程序-GUI界面


    201421123118 张中结    201421123098 胡丹丹

    a.需求分析

        这个程序做成GUI(可以是Windows PC 上的,也可以是Mac、Linux,web,手机上的),成为一个有基本功能、一定价值的程序。在下面的功能需求中实现两个:

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

    b.功能设计

      1.支持语言的切换

      2.计时功能

      3.错题收集

    思维导图:

      

    c.代码展示:

    错题收集并保存在本地

    FileWriter fw = null;
    
                        try {
    
                        //如果文件存在,则追加内容;如果文件不存在,则创建文件
    
                        File f=new File("D:/cuoti.txt");
    
                        fw = new FileWriter(f, true);
    
                        }
    
                        catch (IOException e) {
    
                        e.printStackTrace();
    
                        }
    
                        PrintWriter pw = new PrintWriter(fw);
    
                        pw.println(L8.getText()+"="+T3.getText()+"    "+"正确答案:"+sum1 +'
    ');
    
                        pw.flush();
    
                        try {
    
                        fw.flush();
    
                        pw.close();
    
                        fw.close();
    
                        } catch (IOException e) {
    
                        e.printStackTrace();
    
                        }  
     B6.addActionListener(new ActionListener(){//错题本打开
    
                public void actionPerformed(ActionEvent d) {
    
                    try
    
                    {
    
                    Runtime.getRuntime().exec("notepad.exe D:/cuoti.txt");
    
                    }
    
                    catch(Exception e)
    
                    {
    
                    System.out.println(e.getMessage());
    
                    }
    
                  }
    
                });

    语言切换:

    B3.addActionListener(new ActionListener(){//简体中文
    
                public void actionPerformed(ActionEvent e) {
    
                     L1.setText("题数:");
    
                     L2.setText("题目:");
    
                     L3.setText("输入答案:");
    
                     L4.setText("结果:");
    
                     L5.setText("答对题数:");
    
                     L6.setText("答错题数:");
    
                     L7.setText("答题时间:");
    
                     B0.setText("开始");
    
                     B1.setText("下一题");
    
                     B6.setText("错题集");
    
                    //B2.setText("计时");
    
                }
    
            });
    
            B4.addActionListener(new ActionListener(){//繁体中文
    
                public void actionPerformed(ActionEvent e) {
    
                    L1.setText("題數");
    
                    L2.setText("題目:");
    
                     L3.setText("輸入答案:");
    
                     L4.setText("結果:");
    
                     L5.setText("答對題數:");
    
                     L6.setText("答錯題數:");
    
                     L7.setText("答題時間:");
    
                     B0.setText("開始");
    
                     B1.setText("下一題");
    
                     B6.setText("錯題集");
    
                    
    
                }
    
            });
    
            B5.addActionListener(new ActionListener(){//英文
    
                public void actionPerformed(ActionEvent e) {
    
                     L1.setText("Question number");
    
                     L2.setText("Test:");
    
                     L3.setText("Enter the answer:");
    
                     L4.setText("Result:");
    
                     L5.setText("Right number:");
    
                     L6.setText("Wrong number:");
    
                     L7.setText("Answer times:");
    
                     B0.setText("Run");
    
                     B1.setText("Next");
    
                     B6.setText("WrongTest");
    
                
    
                }
    
            });

    d.调试运行

     e.总结

      两个人一起编程还是第一次,前期在磨合上出现了一些问题,但是也慢慢克服了。我认为开始并没有1+1>2的效果,但是磨合之后,两个人的思路就要比一个人的思路更加广泛,确实能达到大于2的效果。不过我还是喜欢一个人编程,也只是在思路上觉得有人帮助开拓一下还不错。

    码市地址:https://git.coding.net/zzj201421123118/Second2.git

  • 相关阅读:
    微擎模块机制分析2
    微擎we7模块和模板安装方法
    git的使用 及一些常见的错误处理
    人,活着为了什么?
    fedora配置ip
    fedora安装gcc
    linux查看内核版本和发行版本号
    python数据类型2
    python之零碎知识
    python之数据类型1
  • 原文地址:https://www.cnblogs.com/zzj118/p/6550256.html
Copyright © 2020-2023  润新知