结对编程2
2016-04-17 15:00
316 查看
[b]1.结对照片[/b]
![](https://images2015.cnblogs.com/blog/899067/201604/899067-20160419091403882-516044629.png)
2.结对说明
结对对象:蔡何 博客地址:http://www.cnblogs.com/compilers/
双方贡献:1:2
3.题目
构造程序,分别是:
•不能触发Fault。
•触发Fault,但是不能触发Error。
•触发Error,但是不能产生Failure。
4.程序描述
输入两个整数A B ,range in [-100 , 100],若A B都小于 0,则输出 All less than 0;否则就判断A B中的最大值y = max(A,B), y是否处于[25 ,65] 之间,若处于,则输出 25 <= max(A,B) <=65,否则输出 Illegal !
4.源代码:
6.测试
•不能触发Fault。
![](https://images2015.cnblogs.com/blog/899064/201604/899064-20160415161912941-1112093618.png)
•触发Fault,但是不能触发Error。
![](https://images2015.cnblogs.com/blog/899064/201604/899064-20160415162300363-2099288722.png)
•触发Error,但是不能产生Failure。
![](https://images2015.cnblogs.com/blog/899067/201604/899067-20160419091403882-516044629.png)
2.结对说明
结对对象:蔡何 博客地址:http://www.cnblogs.com/compilers/
双方贡献:1:2
3.题目
构造程序,分别是:
•不能触发Fault。
•触发Fault,但是不能触发Error。
•触发Error,但是不能产生Failure。
4.程序描述
输入两个整数A B ,range in [-100 , 100],若A B都小于 0,则输出 All less than 0;否则就判断A B中的最大值y = max(A,B), y是否处于[25 ,65] 之间,若处于,则输出 25 <= max(A,B) <=65,否则输出 Illegal !
4.源代码:
package pair_program_2; import java.util.Scanner; /** * * @author JackCai * @brief 输入两个整数A B ,range in [-100 ,- 100],若A B都小于 0,则输出 All less than 0 * ;否则就判断A B中的最大值y = max(A,B), y是否处于[25 ,65] 之间,若处于,则输出 25 <= max(A,B) <= * 65,否则输出 Illegal ! * */ public class PairProgram2 { public static int opA; /** <opA number */ public static int opB; /** <opB number */ public static int maxValue; /** <maxValue */ private final static int ZERO = 0; private final static int LEG_RANGE_LOW = 25; private final static int LEG_RANGE_HIGHT = 65; private final static int RANGE_LOW = -100; private final static int RANGE_HIGHT = 100; private static Scanner scanner = new Scanner(System.in); /** * @brief this is the main function of this program * @param [in] args */ public static void main(String args[]) { opA = getUserInput(); // 获取操作数A opB = getUserInput(); // 获取操作数B if (opA < ZERO && opB < ZERO) { System.out.println("All less than 0 !"); return; } // otherwise maxValue = max(opA, opB); // 获取两者的MAX值 if (maxValue >= LEG_RANGE_LOW && maxValue <= LEG_RANGE_HIGHT) { // 满足在 // [25,65]之间的话,则输出 System.out.println(LEG_RANGE_LOW + " <= max(" + opA + " , " + opB + ") <= " + LEG_RANGE_HIGHT); } else { System.out.println("Illegal !"); // 否则就输出 Illegal ! } } /** * @brief this function to get the max value between A and B (PS: some fault * in these code) * @param [in] opA * @param [in] opB * @return */ public static int max(int opA, int opB) { int temp = opA; if (opB > opA) { temp = opA; } return temp; } /** * @brief this function to get input data from user * @return int */ public static int getUserInput() { int value = -1; System.out .println("please enter a integer number,range in [-100,100]:"); while (true) { if (scanner.hasNextInt()) { value = scanner.nextInt(); if (value >= RANGE_LOW && value <= RANGE_HIGHT) { break; } else { System.out .println("Illegal range, should be in [-100,100],try again: "); } } else { scanner.nextLine(); // flush cache System.out.println("please enter right number:"); } } return value; } }
6.测试
•不能触发Fault。
![](https://images2015.cnblogs.com/blog/899064/201604/899064-20160415161912941-1112093618.png)
•触发Fault,但是不能触发Error。
![](https://images2015.cnblogs.com/blog/899064/201604/899064-20160415162300363-2099288722.png)
•触发Error,但是不能产生Failure。
![](https://images2015.cnblogs.com/blog/899064/201604/899064-20160415162512488-1003213562.png)
相关文章推荐
- 循序渐进之Spring AOP(5) - 创建切面
- JAVA线程间的状态转换
- PHP之array_keys()获取数组键名
- 第12章--Java集合之Iterator接口的使用
- 【转载】Java的四种引用
- Spring 学习时遇到错误整理贴(会慢慢补充)
- Spring事务配置的五种方式
- Spring Assert(方法入参检测工具类-断言)
- 多线程编程:互斥
- C++ Primer笔记3_默认实參_类初探_名字查找与类的作用域
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- ”ftp使用dos命令“
- java面向对象特征
- Spring3 升级Spring 4
- Exception in thread "main" java.util.ConcurrentModificationExceptions
- java-----ThreadLocal源码分析
- Java技术_Java千百问(0033)_接口和抽象类有什么区别
- php实现三级级联下拉框
- 在python(windows操作系统)中安装、配置Tushare,希望对股票有兴趣的程序员有一点点帮助
- ZBlog你选择PHP还是ASP?