zoukankan      html  css  js  c++  java
  • 软件测试上机作业

    一、junit、hamcrest和eclemma的安装。

    1.junit和hamcrest在新建了junitHw1工程后在build path里通过add external jars添加junit-4.12.jar和hamcrest-all-1.3.jar。

    2.eclemma在eclipse下点击help-eclipse marketplace-find-eclemma安装,重启eclipse。

    二、编程判断三角形是等边三角形、等腰三角形或不等边三角形。

    public class triangle {
        private static int error = 0;
        private static int equilateral = 1;
        private static int isosceles = 2;
        private static int scalene = 3;
        
    
       
        public static int triangletype(int a,int b, int c){
            if(a <= 0 || b <= 0 || c <= 0){
                 return 0; 
            }else if(a + b > c && a + c > b && b + c > a){
            
            if ( a == b && b == c){
                System.out.println("This is a equilateral triangle.");
                return 1;  
            }else if (a == b || a == c || b == c){
                System.out.println("This is a isosceles triangle.");
                 return 2;
            }else {
                System.out.println("This is a scalene triangle.");
                return 3;
            }
            }else{
                return 0; 
           }
        }
            
    }

    创建测试类

    public class triangle {
        private static int error = 0;
        private static int equilateral = 1;
        private static int isosceles = 2;
        private static int scalene = 3;
        
    
       
        public static int triangletype(int a,int b, int c){
            if(a <= 0 || b <= 0 || c <= 0){
                 return 0; 
            }else if(a + b > c && a + c > b && b + c > a){
            
            if ( a == b && b == c){
                System.out.println("This is a equilateral triangle.");
                return 1;  
            }else if (a == b || a == c || b == c){
                System.out.println("This is a isosceles triangle.");
                 return 2;
            }else {
                System.out.println("This is a scalene triangle.");
                return 3;
            }
            }else{
                return 0; 
           }
        }
            
    }

    三、测试结果

  • 相关阅读:
    给VPS装桌面
    GIT免密码PUSH
    验证码类
    Url几个常用的函数
    PHP--关于模板的原理和解析
    管理员权限执行批处理和静默执行regsvr32注册
    linux 维护常见场景小命令 (未完待续)
    批处理定时重启print打印服务,解决打印机异常队列堆积
    Linux----LVM扩容磁盘空间
    6、Samba 服务器配置
  • 原文地址:https://www.cnblogs.com/dpcn/p/5295477.html
Copyright © 2011-2022 走看看