zoukankan      html  css  js  c++  java
  • 结对项目编程

    一、题目描述

      编写程序并测试,分别是:

    1. 不能触发fault
    2. 触发fault,但不触发error
    3. 触发error,但不产生failure

    二、结对伙伴

      屈玉娟  博客:http://www.cnblogs.com/yjuar/

    三、程序代码

      情况一:不能触发fault

    1 num = int(input("请输入一个数:"))
    2 if num > 0 :
    3     print("您输入的是正数")
    4 else:
    5     print("您输入的是负数")

      //程序在第4-5行存在错误,没考虑输入数字为0情况。

      

      //结果存在fault,但没触发。

      情况二:触发fault,但不触发error

     1 #输入三个变量,然后按小到大输出
     2 x = int(input('please input x:'))
     3 y = int(input('please input y:'))
     4 z = int(input('please input z:'))
     5 if x > y :
     6     x, y = y, x
     7 if x > z :
     8     x, z = z, x
     9 if y > z :
    10     y, z = z, y
    11 print("从小到大排序后")
    12 print(z,y,x)

      //12行有fault,没按从小到大顺序输出。

      

      //结果触发了fault,但没触发Error。

      情况三:触发error,但不产生failure

     1 #输入三个变量,然后按小到大输出
     2 x = int(input('please input x:'))
     3 y = int(input('please input y:'))
     4 z = int(input('please input z:'))
     5 if x > y :
     6     x, y = y, x
     7 if x > z :
     8     x, z = z, x
     9 if y > z :
    10     y, z = z, y
    11 print("从小到大排序后")
    12 print(z,y,x)

      

      //结果触发error,但不产生failure

    三、总结

      通过这几个小例子,对error,failure,fault的概念理解得更透彻清晰,和队友的配合也更有默契。

  • 相关阅读:
    HtmlAgilityPack
    随笔-20150513
    过滤掉html 标签
    json转换
    第28月第3天 c语言读写文件
    第27月第28天 iOS bundle
    第27月第27天 https
    第27月第25天 clang -rewrite-objc main.m
    第27月第24天 git pull fetch
    第27月第18天 epoll lt et
  • 原文地址:https://www.cnblogs.com/xiayi/p/5408902.html
Copyright © 2011-2022 走看看