zoukankan      html  css  js  c++  java
  • 任务三 简单程序测试及 GitHub Issues 的使用

    我提交的Issue

    我被提出的Issue

    在使用Issue的过程中我发现提出的Issue不能指派任务人和问题类型,被提出的Issue可以。

    碰到最多的问题是测试程序的过程中, 比如用户未按指定格式输入字符如何处理,如何实现问题不重复等,刚碰到这个问题时,我认为可以用分支语句实现,但是发现分支结构会十分庞杂,

    后来我想起来一个错误检测分支,try catch。

      

    try{
    count=input.nextInt();
    }catch (Exception e){
    System.out.println("Error");
    try {
    Thread.sleep(5000);
    } catch (InterruptedException e1) {
    System.exit(0);
    }
    System.exit(0);
    }

    这样直接实现了非Int型变量不允许通过

    不重复问题使用数组,但是一般的数组大小难以定量,因为不知道用户会希望出多少道题,所以后面我用ArrayList<String>记录已经出现的问题

    arithmeticArray.get(arr_size).equals(arithmeticStr)

    但是加法与乘法的重复如 3+2与2+3,5*6与6*5等一并算入重复的算式不能简单的通过判断相同来实现。

    这里我借用了StringBuffer类里的reverse方法。将算式反制再判断相同。实现杜绝重复出题。

    StringBuffer sb = new StringBuffer();
    sb.append(arithmeticStr);

    (sign == '+' || sign == '×') && sb.reverse().toString().equals(arithmeticArray.get(arr_size)))


  • 相关阅读:
    在Win8下无法打开 hlp 帮助文件的问题
    ftp 终端命令
    为 Macbook 增加锁屏热键技巧
    苹果系统直接读写 ntfs 磁盘
    div 绝对布局居中
    2015-1-11
    unable to load default svn client
    ubuntu eclipse 安装svn
    centos mysq table is read only
    centos ssh 乱码
  • 原文地址:https://www.cnblogs.com/transWang/p/6613905.html
Copyright © 2011-2022 走看看