softwareTesting_work2_question1
- 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() {
} } - 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);
// }
} //测试用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);
// }
}- 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的更多相关文章
随机推荐
- VA01复制单据,更新定价日期和价格
用户经常复制单据,而复制单据的时候会带过来很多日期的历史数据.定价日期就是其中之一,而价格经常变动,或者删除的话,会出现价格错误等等情况. 1.更新定价日期,保证不会使用历史价格. 2.更新价格,保证 ...
- Android开发--ListView的应用
1.简介 ListView用于以列表的形式展示数据.它在装载数据时,不能使用ListView类的add()等相关方法添加,而要借助Adapter对象进行添加.另外,由于 系统提供的Adapter往往不 ...
- JS中关于clientWidth offsetWidth scrollWidth 等的含义
网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...
- POJ1635 树的最小表示
/*zoj1990Subway Tree Systems题目大意:初始时站在树的根节点,若朝着远离根的方向走,记录“”,接近根的方向走记录“”.并且树的每一条边只能来回走一次(即向下和返回).一个合法 ...
- 在ubuntu中安装psutil
环境:ubuntu 16.04 LTS + python 2.7/3.5共存 + psutil 4.3.0 1.sudo apt-get install python3-dev # 先把python3 ...
- CALayer 详解 -----转自李明杰
本文目录 一.什么是CALayer 二.CALayer的简单使用 回到顶部 一.什么是CALayer * 在iOS系统中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个 ...
- daydayup1 codeforces141c
题意:给定n个数字,代表每个人前面有几个人比他高,让你构造一个height数组,满足条件 思路:直接贪心就好,假设到第i个人,设他的高度为i-a[i]+1,前面比他高的人每个人的高度加1
- code of C/C++(2)
初学者学习构造函数和析构函数,面对如何构造的问题,会头大.这里提供了变量(int,double,string),char *,字符数组三个类型的私有成员初始化的方法 //char * 类型的成员,如何 ...
- Firebug的下载安装
网上下载到的Firebug最后得到的都是一个.xpi文件 这个文件直接从文件夹拖入火狐浏览器就可以完成安装了,但浏览器总会告诉你无法通过验证.... 这时候你只需要在火狐浏览器中输入about:con ...
- JS技术大全
事件源对象:event.srcElement.tagName event.srcElement.type 捕获/释放:event.srcElement.setCapture(); event.sr ...