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. JavaScipt 数据交互

    标准的w3c直接提供了XMLHttpRequest方法,我们主要站在设计的角度来理解,如何设计出低耦合高内聚的代码jquery对Ajax的处理主要体现在对浏览器兼容,数据的处理过滤以及各种事件的封装上 ...

  2. ios基础篇(三十)—— AFNetworking的使用

    一.AFNetworking的创建 1.新建工程,命名为AFNDemo 2.导入AFNetworking.h AFNetworking文件下载:https://github.com/AFNetwork ...

  3. [原创]导出CSV文件,特殊字符处理。

    CSV文件格式 1.CSV文件默认以英文逗号(,)做为列分隔符,换行符(\n)作为行分隔符.2.CSV默认认为由""括起来的内容是一个栏位,这时不管栏位内容里有除"之外字 ...

  4. UVA 11624 Fire!

    题目大意: F代表火焰 J代表人 一个人想在火焰烧到自己之前逃出着火地区 . 为路,人可以走,火可以燃烧(当然如果火先烧到就不能走了) #为墙,不可走 如果能逃出,输出时间,不能,输出IMPOSSIB ...

  5. ORACLE 自定义聚合函数

    用户可以自定义聚合函数  ODCIAggregate,定义了四个聚集函数:初始化.迭代.合并和终止. Initialization is accomplished by the ODCIAggrega ...

  6. 华为地铁换乘 Java

    public class MetroTransfor {        static int ver=37;    static int point=35;    static int [][] di ...

  7. CSS3回执特殊图形

  8. bcd-ascii相互转换函数

    // BCD转ASCII int Asc2Bcd(unsigned char *input, unsigned int inputLen, unsigned char *output) { unsig ...

  9. jQuery.attr() 函数详解

    一,jQuery.attr()  函数详解: http://www.365mini.com/page/jquery-attr.htm 二,jQuery函数attr()和prop()的区别: http: ...

  10. window下关闭nginx

    nginx -s stop taskkill /F /IM nginx.exe > nul