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的更多相关文章
随机推荐
- C#中XML和json互相转换
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xm ...
- css学习归纳总结(二) 转
原文地址:css学习归纳总结(二) 标签与元素 <p>标签和p元素有什么区别呢?大多数时候他们表示的是同一样东西,但仍有细微的区别.<p>.<div>等指的是HTM ...
- Oracle管理口令遗忘解决办法
刚装Oracle11g后忘记了安装时设置的管理口令,可以通过如下方法重置指定用户名密码: 1.打开sql plus,在“请输入用户名”提示符后输入“/as sysdba”,链接数据库后通过“alter ...
- Wpf之Xaml属性值和特性值(一)
其实我一直很好奇在xaml中,通过Attribute=Value这种方式可以进行对元素的描述, 例如: <Rectangle Name=” rectangle” Fill=”Blue”/> ...
- Practical Malware Analysis里有关inetsim\APATEDNS
以前从未接触过linux,碰到了许多问题,按步骤: 1\安装VMWARE,安装ubuntu16.04 问题1:之前装的是VM10,装完后没有安装VMTOOLS,我点安装 VMTOOLS,它弹出“简易安 ...
- 关于XE10下Indy发送字符串编码的问题
在与硬件对接的过程中,之前用D7环境下的UDPServer.Post发送的指令,硬件可正常识别并正常显示, 后来使用到XE10,重新编译之前的源码,发现所有汉字乱码显示了: 后通过对接收数据发现,实际 ...
- Python中的下划线(译文)
原文地址这篇文章讨论Python中下划线_的使用.跟Python中很多用法类似,下划线_的不同用法绝大部分(不全是)都是一种惯例约定. 单个下划线(_) 主要有三种情况: 1. 解释器中 _符号是指交 ...
- XP 安装不了framework 4.0 的解决方法
第一步: 如果是XP系统: 1.开始——运行——输入cmd——回车——在打开的窗口中输入net stop WuAuServ 2.开始——运行——输入%windir% 3.在打开的窗口中有个文件夹叫So ...
- 第二篇.Bootstrap起步
第二篇Bootstrap起步 我们可以在http://getbootstrap.com下载bootstrap的文件 点击左边的download bootstrap可以下载bootstrap的css,j ...
- iframe 简单的一个用法 局部调用
<iframe id="main_com" name="main_com" width="100%" height="750 ...