• 软件工程(2019)结对编程第二次作业


    一、题目要求

    - 本次作业有两个题目,经过讨论选择做小学四则运算自动生成程序,题目要求如下: (1)能够自动生成四则运算练习题; (2)可以定制题目数量 (3)用户可以选择运算符 (4)用户设置最大数(如十以内、百以内等) (5)用户选择是否有括号、是否有小数 (6)用户选择输出方式(如输出到文件、打印机等) (7)最好能提供图形用户界面(根据自己能力选做,以完成上述功能为主)

    二、角色分配

    本次作业要求两个人合作完成,驾驶员和导航员两个角色:

    • 驾驶员:谢保华
      基本完成全部代码工作,程序基本实现全部要求功能,并将代码上传到GitHub代码托管系统(此处附代码地址)中,
      并对导航员在本次编程工作中起到的作用给出客观评价;
    • 导航员:陈鹏
      辅助驾驶员完成全部代码工作,并且为关键函数选用合适的覆盖标准设计测试用例,并编写代码进行单元自动测试,并且根据代码检查表对驾驶员的本次工作进行评价;

    三、功能实现

    - 首先根据题目定义了小数点、括号及加减乘除允许位: ``` static int Question_point=0; static int Question_bracket=1; static int Question_plus=1; static int Question_minus=1; static int Question_multiply = 1; static int Question_divid = 1; ``` - 根据get_question(int Number_MAX)函数来实现输入要求四则运算中的最大数值: ``` public static String get_question(int Number_MAX) { int bracket_n = 0; String ques = ""; int i; if( Question_bracket == 1){ //i = 4; i = 1 + (int) (Math.random() * 5); //bracket_n = 2 + (int)(Math.random() * 2); //随机括号位置 bracket_n = 1 + (int)(Math.random() * i); } else i = 1 + (int) (Math.random() * 4); int factor; String oper = ""; factor = 1 + (int) (Math.random() * Number_MAX); // 产生大于1小于Number_MAX的随机数 ques = ques + factor; if(Question_point == 1){ factor = 1 + (int) (Math.random() * 100); // 产生两位小数部分 ques = ques + '.' + factor; } while(i!=0){ i--; oper = operator.get((int) (Math.random() * oper_NUM));// 产生随机符号 ques = ques + oper; if(Question_bracket == 1 && bracket_n + i == 5) ques = ques +'('; factor = 1 + (int) (Math.random() * Number_MAX); // 产生大于1小于Number_MAX的随机数 ques = ques + factor; if(Question_point == 1){ factor = 1 + (int) (Math.random() * Number_MAX); // 产生两位小数部分 ques = ques + '.' + factor; }
    		if(Question_bracket == 1 && bracket_n + i == 3)
    			ques = ques +')';
    	}
    	return ques + '=' + "
    " ;
    }
    
    - 以get_questions(int Question_MAX,int Number_MAX)函数根据输入问题的最大值和设定数的最大值来产生随机产生四则运算式:
    

    public static void get_questions(int Question_MAX,int Number_MAX) {
    int i;

    	for (i = 0; i < Question_MAX; i++) {
    		questions.add(get_question(Number_MAX));
    	}
    
    - 根据showQuestions() throws IOException函数功能来实现随机产生的四则运算并且写到“F:\log.txt”文本中:
    

    public static void showQuestions() throws IOException {
    String str;
    Iterator iterator = questions.iterator();
    FileWriter fw=new FileWriter("F:log.txt");
    while (iterator.hasNext()) {
    str = iterator.next();
    System.out.println(str);
    fw.write(str);
    }
    fw.flush();
    fw.close();

    </font><br/>
    
    ##<font color=DodgerBlue>四、运行结果</font>
    <font size="3">
    - 实现在控制台输出:
    ![](https://img2018.cnblogs.com/blog/1647652/201905/1647652-20190504105916069-1275582936.png)
    - 实现在文本输出:
    ![](https://img2018.cnblogs.com/blog/1647652/201905/1647652-20190504110011153-1051977552.png)
    </font><br/>
    
    ##<font color=DodgerBlue>五、评价总结</font>
    <font size="3">&emsp;&emsp;在结对编程的过程中,我在和陈鹏同学的配合中学到了很多,我们不断讨论新的方法,不断的查找bug,致使开发效率比一个人的时候快了好几倍;
    &emsp;&emsp;在代码结构上对我的原始代码进行整合,使得代码更加规范,结构更加清晰;我的结对伙伴非常的优秀,首先通过结对编程,可以督促我更加努力学习,也对各种的编程思路有了新的了解;
    &emsp;&emsp;其次,这是一次两个人作为一个团队之间的交流,通过这次结对编程,学习到了很多团队中应该具有的一些分工和能力,同时也提高自身的能力和专业水平,同时通过这次驾驶员经历,让我对结对编程和程序员之间的配合有了更深入的了解,对以后的学习和帮助有很大的帮助。
    </font><br/>
  • 相关阅读:
    order by子句
    having和where的区别
    O2O模式为什么这么火
    高德----------百度地图
    list后台转化为JSON的方法ajax
    ajax中后台string转json
    ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    压缩文件解压
    个人作业3——个人总结(Alpha阶段)
    第08周-集合与泛型
  • 原文地址:https://www.cnblogs.com/xbh-xr/p/10807676.html
Copyright © 2020-2023  润新知