1. input类

    package com.Phantom;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Map.Entry; public class inputs {
    public int times;
    public int getTimes() {
    return times;
    }
    public void setTimes(int times) {
    this.times = times;
    }
    public inputs(int times, String words) {
    super();
    this.times = times;
    this.words = words;
    } public String words;
    Map<String, Integer>map=new HashMap<String, Integer>();
    List<Entry<String, Integer>>list=new ArrayList<Map.Entry<String,Integer>>();
    // public String getWords() {
    // return words;
    // }
    public void setWords(String words) {
    this.words = words;
    } public Map<String, Integer> getMap() {
    return map;
    }
    // public void setMap(Map<String, Integer> map) {
    // this.map = map;
    // }
    // public List<Entry<String, Integer>> getList() {
    // return list;
    // }
    // public void setList(List<Entry<String, Integer>> list) {
    // this.list = list;
    // } public inputs() {
    } }
  2. operation类
    package com.Phantom;
    
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.Map.Entry;
    import java.util.Scanner;
    import java.util.Set; public class operation {
    inputs i=new inputs();
    public String in(int times,String input){
    Scanner in=new Scanner(System.in);
    String words=in.nextLine(); i.setWords(words);
    String[] items = words.split(" "); for(String s:items){
    if (i.map.containsKey(s)) {
    i.map.put(s, i.map.get(s)+1);
    }
    else{
    i.map.put(s, 1);
    }
    } for(Entry<String, Integer>entry:i.map.entrySet()){
    i.list.add(entry);
    } System.out.println("单词"+"\t"+"出现频率");
    for (Entry<String, Integer> obj : i.list) {
    i.times=obj.getValue();
    System.out.println(obj.getKey() + "\t" + i.times);
    }
    //测试
    // System.out.println(i.map);
    // System.out.println(i.map.values());
    // i.map.put("aaa", 3);
    // Set<Entry<String, Integer>>e=i.map.entrySet();
    // System.out.println(i.map);
    // System.out.println(i.map.get("aaa"));
    // System.out.println(i.map.values().size());
    // System.out.println(i.map.toString());
    return words;
    } //测试
    // public static void main(String[] args) {
    // // TODO Auto-generated method stub
    // System.out.println("请输入内容:");
    // inputs i=new inputs(0, null);
    // operation o=new operation();
    // o.in(0, null);
    // }
    }
  3. //测试用main函数
    // public static void main(String[] args) {
    // // TODO Auto-generated method stub
    // System.out.println("请输入内容:");
    // inputs i=new inputs(0, null);
    // operation o=new operation();
    // o.in(0, null);
    // }
    }

  4. testing类
    package com.Phantom;
    
    import static org.junit.Assert.*;
    import junit.framework.TestCase; import org.junit.Before;
    import org.junit.Test; public class testingOperation extends TestCase{
    private operation o1;
    inputs i1=new inputs(0, null);
    @Before
    public void setUp() throws Exception {
    super.setUp();
    o1=new operation();
    } public void testOperation() {
    i1.setWords("aaa aaa aaa");
    i1.setTimes(3);
    i1.map.put("aaa", 3);
    assertTrue(o1.in(i1.getTimes(), i1.map.toString())==i1.map.get("aaa")+"aaa aaa aaa");} @Override
    protected void tearDown() throws Exception {
    // TODO Auto-generated method stub
    super.tearDown();
    System.out.println("getMap"+i1.getMap());
    } }

junit

覆盖率

softwareTesting_work2_question1的更多相关文章

随机推荐

  1. EntityFrameWork使用MySql数据库分页的BUG

    环境 使用MySQL Connector NET 6.7.4+EF5.0+VS2010 问题描述 IQueryable<T>类型的Where方法和Skip或Take方法一起使用时,生成的S ...

  2. 很重要的vue的生命周期

  3. .net下开发ActiveX控件

    `   ActiveX 是一个开放的集成平台,为开发人员. 用户和 Web生产商提供了一个快速而简便的在 Internet 和 Intranet 创建程序集成和内容的方法. 使用 ActiveX, 可 ...

  4. [转载]GlassFish 的安装及设置命令

    移步: http://blog.csdn.net/joyous/article/details/8008870

  5. C# 中 多线程同步退出方案 CancellationTokenSource

    C# 中提供多线程同步退出机制,详参对象: CancellationTokenSource CancellationTokenSource 中暂未提供复位操作,因此当调用Cancle 之后,若再次调用 ...

  6. Bootstrap<基础九>辅助类

    Bootstrap 中的一些可能会派上用场的辅助类. 文本 以下不同的类展示了不同的文本颜色.如果文本是个链接鼠标移动到文本上会变暗: 类 描述   .text-muted "text-mu ...

  7. (转发)centos,redhat 系统为php安装memcached扩展

    转自:http://www.itnose.net/detail/6111623.html 1. 通过yum安装 yum -y install memcached #安装完成后执行: memcached ...

  8. mysql 操作杂记

    SHOW VARIABLES LIKE 'character%'; SET character_set_client = utf8; SET character_set_connection = ut ...

  9. Ubuntu下freeradius-server的安装与mysql-server的关联

    1.创建freeradius数据库 #service mysql start ... #mysql -u root -p Enter password: 456456 ... mysql> cr ...

  10. redhat 安装 jdk1.7 问题

    redhat 安装 jdk 后出现 dl failure on line 685Error: failed /usr/local/jdk1.6.0_10/jre/lib/i386/client/lib ...