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. Python笔记总结week8

    面向对象第二节 要点: 1. 封装,对象中嵌套对象 2. pickle,load,切记,一定要先导入相关的类 回顾上一节: 面向对象三大特性: 封装.继承.多态(多种类型.多种形态) 关于多态,任意参 ...

  2. java selenium (十) 操作浏览器

    本篇文章介绍selenium 操作浏览器 阅读目录 浏览器最大化 前进,后退, 刷新 public static void testBrowser(WebDriver driver) throws E ...

  3. C++ 读取txt文本内容,并将结果保存到新文本

    循序渐进学习读文件 // readFile.cpp : 定义控制台应用程序的入口点. #include "stdafx.h" #include <iostream> # ...

  4. 使用R进行地图相关的可视化

    Here is a solution using the geosphere and maps package. Using the gcIntermediate function you can & ...

  5. [Matlab] 如何在矩阵中查找特定的字符串

    题目 A = {'abcd','efgh','ijkl'; 'bd3','skge','zxe2'}:怎样查找A中字符串的是否含有字符串"bd3",如有返回字符串所在的行号和列号. ...

  6. 修改UISearchBar的背景颜色

    当你看到这篇博客你就已经发现了用_searchBar.backgroundColor = [UIColor clearColor];来设置UISearchBar的颜色完全没有效果: 并且,有些方法是想 ...

  7. CentOS7.1下JDK+Tomcat应用环境搭建

    最近由于项目的原因,需要测试Linux环境下的应用部署情况.选用了CentOS7.1版本+JDK1.6版本+Tomcat7.0版本进行搭建.其间各种折磨就不说了,随手把相关的注意事项和大概的步骤记录下 ...

  8. Linux学习 : 自己写bootloader

    一.bootloader 目标:启动内核 基本功能: ①初始化硬件:关看门狗.设置时钟.设置SDRAM.初始化NAND FLASH ②image比较大需要重定位到SDRAM ②将内核从NAND FLA ...

  9. 【转】Tomcat的默认访问路径

    放在外网的应用,用户多是直接输入域名访问,相信没有哪个后面还加个尾巴,而Tomcat的默认目录是ROOT,所以我们需要更改其默认目录. 更改Tomcat的默认目录很简单,只需要修改server.xml ...

  10. iOS开发学习概述及知识整理

    设计师设计出来了一个不错的引导界面,然而当我看到设计稿的时候,我们的app也没几天就要上线了.这个界面模仿了Evernote iOS app的风格. 我以迅雷不及掩耳盗铃之势开始在Xcode上编程,用 ...