• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
爪哇键盘手
博客园    首页    新随笔    联系   管理    订阅  订阅

软件测试上机作业

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

三、测试结果

 

posted @ 2016-03-19 16:15  dpcn  阅读(346)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3