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; 
           }
        }
            
    }

    三、测试结果

  • 相关阅读:
    ubuntu16.04使用anaconda创建python虚拟环境
    Ubuntu16.04里安装anaconda3后将python第三方包安装到指定目录下
    conda把包安装到当前激活的环境中
    ubuntu修改环境变量
    conda安装tensorflow
    ASP VNext 开源服务容错处理库Polly
    EntityFramework实现指定字段的通用赋值
    NET流行高性能JSON框架-Json.NET
    .NET网站国际化策略
    软件开发工作流-GitFlow
  • 原文地址:https://www.cnblogs.com/dpcn/p/5295477.html
Copyright © 2011-2022 走看看