ww

软工结对编程

1. 博客地址

博客地址

2. 结对小伙伴的学号、博客地址,结对项目的码云地址

成员学号 成员姓名 项目地址
201621123008 周文华 https://www.cnblogs.com/Dzwh/
201621123002 肖文婷 https://www.cnblogs.com/xwt2017/
. . https://gitee.com/Dzwh/PairProject-Java/tree/master/008-002

3. 结对的PSP表格

PSP2.2 结对开发流程 结对开发流程 实际耗费时间(分钟)
Planning 计划 30 50
Estimate 明确需求和其他相关因素,估计每个阶段的时间成本 50 70
Development 开发 650 700
Analysis 需求分析 (包括学习新技术) 500 650
Design Spec 生成设计文档 100 150
Design Review 设计复审 60 70
Coding Standard 代码规范 50 30
Design 具体设计 200 160
Coding 具体编码 180 200
Code Review 代码复审 60 50
Test 测试(自我测试,修改代码,提交修改) 60 190
Reporting 报告 100 190
· 测试报告 40 40
· 计算工作量 60 60
· 并提出过程改进计划 50 30

4. 解题思路

  1. 编程语言:java

  2. 编译环境:eclipse,netbrans

  3. 具体思路:本次实验使用netbeans实现GUI界面的搭建,最主要就是通过使用JFilechooser控件来实现用户对文件的选择,再调用函数将需要统计文件的路径传递给相应的逻辑处理对象,处理结束后将统计数输出。

5. 设计实现过程

1. 相关类

  • FileUtil:存放与文件读写相关的方法。

  • WordUtil:存放对单词进行排序分类等相关操作。

  • Main: 测试类

2 . 对应方法

FileUtil类:

  • readFile方法:读取文档,并对其中字符进行统计。

WordUtil类

  • sortWord方法:对单词进行排序输出。

3. 单元测试

实验截图:


6. 代码说明

  private void choiceActionPerformed(java.awt.event.ActionEvent evt) {                                       
        JFileChooser chooser=new JFileChooser();
        int returnVal=chooser.showOpenDialog(this);
        
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            filename.setText(chooser.getSelectedFile().getPath());
            String path=chooser.getSelectedFile().getPath();
 System.out.println("You chose to open this file: " +
            chooser.getSelectedFile().getName());
 
        FileRead fileRead = new FileRead();
        WordCount count=fileRead.readTxtFile(path);
        
        if(count==null){
            
        }else{
          List<Map.Entry<String,String>> list=count.sortMap();
          characters.setText(String.valueOf(count.getCharacters()));
          Words.setText(String.valueOf(count.getWords()));
  lines.setText(String.valueOf(count.getLines()));
         
           System.out.println("characters:"+count.getCharacters());
            System.out.println("words:"+count.getWords());
            System.out.println("lines:"+count.getLines());
             String ss="";
        if(list.size()<10){
           
            for(int i=0;i<list.size();i++){
               
                ss=ss+"<"+list.get(i).getKey()+">:"+list.get(i).getValue()+"\n";
               
            }
            other.setText(ss);
        
        } else{
            ss="";
               for(int i=0;i<10;i++){
                   
                ss=ss+"<"+list.get(i).getKey()+">:"+list.get(i).getValue()+"\n";
                
                  
                }
                  other.setText(ss);
            }
        }
	}
 }                  

分析:当点击按钮触发事件后,后台就会生成一个JFilechooser对象,调用showOpenDialog(this)方法,其作用是新建一个局部变量可以保存文件路径,再经过处理之后将结果输出到文本域里。

	Scanner sc=new Scanner(System.in);
		System.out.println("查询单词的长度:");
		int num=sc.nextInt();
		
		FileRead fileRead = new FileRead();
		WordCount count = fileRead.readTxtFile("test\\classes\\1.txt");
		if (count == null) {
			System.out.println("文件里的数据为空");
		} else {
			List<Map.Entry<String, String>> list = count.sortMap();
			System.out.println("characters:" + count.getCharacters());
			System.out.println("words:" + count.getWords());
			System.out.println("lines:" + count.getLines());
			if (list.size() < 10) {
				for (int i = 0; i < list.size(); i++) {
					if (list.get(i).getKey().length() == num || num==0) {
						System.out.println("<" + list.get(i).getKey() + ">:" + list.get(i).getValue());
					}
				}
			} else {
				for (int i = 0; i < 10; i++) {
					if (list.get(i).getKey().length() == num || num==0) {
						System.out.println("<" + list.get(i).getKey() + ">:" + list.get(i).getValue());
					}
				}
			}

		}
		System.out.println(args);
	}

分析:任意输入单词长度,当输入0时默认输出全部统计结果。

7. 结合在构建之法中学习到的相关内容与结对项目的实践经历,描述结对的感受,是否1+1>2?

刚开始的时候磨合很重要,要想有效率的进行编程达到1+1>2的效果就必须提前把编程思路和需求分析先讨论确定下来,然后就是调试的时候,有些小细节可能你自己会忽视掉,两个人一起调试的话更容易发现问题,加之两个人在磨合之后一起编程得过程中还是很有趣的。

posted on 2018-10-07 21:10  网络1611肖文婷  阅读(133)  评论(2)    收藏  举报

导航