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. Best Time to Buy and Sell Stock III [LeetCode]

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  2. angularjs 嵌套控制器,子控制器访问父控制器

    <pre> http://www.lovelucy.info/understanding-scopes-in-angularjs.html http://blog.csdn.net/jfk ...

  3. 矩阵k次幂 采用三重循环

    #include<iostream> using namespace std; int main() { int n,k; ][],b[][],c[][]; while(cin>&g ...

  4. Practical Malware Analysis里有关inetsim\APATEDNS

    以前从未接触过linux,碰到了许多问题,按步骤: 1\安装VMWARE,安装ubuntu16.04 问题1:之前装的是VM10,装完后没有安装VMTOOLS,我点安装 VMTOOLS,它弹出“简易安 ...

  5. Flexbox,更优雅的布局

    在设计的眼中,排版的操作是一件很简单的事情,靠左.置中.靠右,我只要点一下,所有元素,就会乖乖的到指定的位置. 但到了前端在排版的实现上,就不是这样了. 我们常常得用一堆其实本来不是这样用的属性来做 ...

  6. java异常处理的设计

    有一句这样话:一个衡量Java设计师水平和开发团队纪律性的好方法就是读读他们应用程序里的异常处理代码. 本文主要讨论开发Java程序时,如何设计异常处理的代码,如何时抛异常,捕获到了怎么处理,而不是讲 ...

  7. 《JavaScript高级程序设计》读书笔记--(2)基本概念

    变量 Javascript 是区分大小写的, 也就是说 var nun 与 var Num 是不同的变量. ECMAScript的变量是松散类型的,所谓松散类型就是可以保存任何类型的数据.ECMASc ...

  8. Rhel6-csync配置文档

    系统环境: rhel6 x86_64 iptables and selinux disabled 主机:192.168.122.160 server60.example.com 192.168.122 ...

  9. js正则实现二代身份证号码验证详解

    js正则实现二代身份证号码验证详解 根据[中华人民共和国国家标准 GB 11643-1999]中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成.排列顺序从左至 ...

  10. codeforces problem 140E New Year Garland

    排列组合题 题意 用m种颜色的彩球装点n层的圣诞树.圣诞树的第i层恰由l[i]个彩球串成一行,且同一层内的相邻彩球颜色不同,同时相邻两层所使用彩球的颜色集合不同.求有多少种装点方案,答案对p取模. 只 ...