zoukankan      html  css  js  c++  java
  • 结对编程(二)

    点滴成就

    学习时间

    新编写代码行数

    博客量(篇)

    学到知识点

     

     

     

     

     

    第一周

    8h

    0

    0

    组成团队,角色分配

    第二周

    8h

    0

    1

    确定团队项目

    第三周

    12h

    0

    1

    使用博客,制作调查问卷,环境图

    第四周

    14h

    105

    1

    软件需求文档,用例图,需求分析结对编程,代码规范

     第五周

     12h

     0

     0

     类图

    第六周

    10h

    200

    0

    顺序图,状态图

     第七周

    14h

     0

     1

     软件系统设计文档,软件测试

    第八周

    10h

    65

    1

    等价类的划分

    结对对象:王良辉2013110436
     
    双方贡献比例:  1:1
     
    结对照片
     
    题目:
    构造程序,分别是:
    •不能触发Fault。
    •触发Fault,但是不能触发Error。
    •触发Error,但是不能产生Failure。
     
    源程序
    提示用户输入两个值,两个值必须在0~100,若不满足条件则提示错误,若两个值都小于10,则输出输入都小于10,程序退出。否则根据输入的值判断使用加法还是减法,若输入的第一个数小于第二个数,则使用减法计算,否则就使用加法。
     1 package wpy.test;
     2 
     3 import java.util.Scanner;
     4 
     5 public class test {
     6     private static Scanner in = new Scanner(System.in);
     7     private static final int RANGE_LOW = 0;// 允许用户输入的最小值
     8     private static final int RANGE_HIGH = 100;// 允许用户输入的最大值
     9     private static final int LIMIT = 10;
    10     private static int result;// 返回结果
    11 
    12 
    13     public static int getUserInput() {
    14         int number = -1;
    15         System.out.println("请输出0~100的整数!");
    16         while (true) {
    17             if (in.hasNextInt()) {
    18                 number = in.nextInt();
    19                 if (number > RANGE_HIGH || number < RANGE_LOW) {
    20                     System.err.println("输入不在1~100!");
    21                 } else {
    22                     break;
    23                 }
    24             } else {
    25                 in.nextLine();
    26                 System.out.println("请输入整数!");
    27             }
    28         }
    29         return number;
    30     }
    31 
    32 
    33     public static int getResult(int num1, int num2) {
    34         if (num1 < num2) {
    35             return num1 + num2;
    36         }
    37         return num1 + num2;
    38     }
    39 
    40     public static void main(String[] args) {
    41         int op1 = getUserInput();
    42         int op2 = getUserInput();
    43         System.out.println("******************************************************");
    44         System.out.println("第一次输入 " + op1 + "      第二次输入 " + op2);
    45         if (op1 < LIMIT && op2 < LIMIT) {
    46             System.out.println("输入都小于 10!!!");
    47             return;
    48         }
    49         result = getResult(op1, op2);
    50         if (result > 0) {
    51             if (result > 100) {
    52                 System.out.println("Illegal!");
    53             } else {
    54                 System.out.println("和为 " + result);
    55             }
    56         } else {
    57             if (result < -50) {
    58                 System.out.println("Illegal!");
    59             } else {
    60                 System.out.println("差为 " + result);
    61             }
    62         }
    63     }
    64 
    65 }

    测试结果

    •不能触发Fault。

      •触发Fault,但是不能触发Error。

      •触发Error,但是不能产生Failure。

    总结

     通过这次结对编程,对软件中fault,error,failure 有了更深一步的认识和理解.

  • 相关阅读:
    使用 Dockerfile 定制镜像
    UVA 10298 Power Strings 字符串的幂(KMP,最小循环节)
    UVA 11090 Going in Cycle!! 环平均权值(bellman-ford,spfa,二分)
    LeetCode Best Time to Buy and Sell Stock 买卖股票的最佳时机 (DP)
    LeetCode Number of Islands 岛的数量(DFS,BFS)
    LeetCode Triangle 三角形(最短路)
    LeetCode Swap Nodes in Pairs 交换结点对(单链表)
    LeetCode Find Minimum in Rotated Sorted Array 旋转序列找最小值(二分查找)
    HDU 5312 Sequence (规律题)
    LeetCode Letter Combinations of a Phone Number 电话号码组合
  • 原文地址:https://www.cnblogs.com/wpy0032/p/5405805.html
Copyright © 2011-2022 走看看