序言

合作伙伴

201631062220      201631062120

项目码云地址:

https://gitee.com/zhege/WordCount

作业详细要求

系统分析与设计结对项目

正文

1.概述

该项目的PSP表格如下

2.互审代码

李欣 TO 王筱哲 :逻辑写的非常不错,唯一不足的是注释有点少,希望以后多写注释

王筱哲 TO 李欣  :思路很清楚,感觉还不错

基本功能基本一样,扩展功能主要是分成几个class,都有点困扰,代码不是那么清楚,都有所改动,最后基本一致

3.程序设计实现过程

1.结构图

2.UML类图

3.属性方法

属性

public int chars;
public int words;
public int lines;
public int codeLines; //代码行数
public int empLines; //空行数
public int comLines; //注释行数 public int getChars() {
return chars;
} public int getWords() {
return words;
} public int getLines() {
return lines;
} public int getCodeLines() {
return codeLines;
} public int getEmpLines() {
return empLines;
} public int getComLines() {
return comLines;
}

WC

 public static String inputFile;
public static String outputFile;
public static boolean needC;
public static boolean needW;
public static boolean needL;
public static boolean needO;
public static boolean needS; //输入参数中是否有“-s”
public static boolean needA; //输入参数中是否有“-a”
public static boolean needE; //输入参数中是否有“-e”

Main

 方法

//实现参数的选择

package wc;

import java.io.*;
import java.util.ArrayList; public class Main {
public static String inputFile;
public static String outputFile;
public static boolean needC;
public static boolean needW;
public static boolean needL;
public static boolean needO;
public static boolean needS; //输入参数中是否有“-s”
public static boolean needA; //输入参数中是否有“-a”
public static boolean needE; //输入参数中是否有“-e” public static void main(String[] args) {
inputFile = "";
StopList.stopList="";
for (int i = 0; i < args.length; i++) {
System.out.println(args[i]);
if ("-c".equals(args[i])) {
needC = true;
} else if ("-w".equals(args[i])) {
needW = true;
} else if ("-l".equals(args[i])) {
needL = true;
} else if ("-s".equals(args[i])) {
needS = true;
} else if ("-a".equals(args[i])) {
needA = true;
} else if ("-e".equals(args[i])) {
needE = true;
StopList.stopList = args[i + 1];
} else if ("-o".equals(args[i])) {
needO = true;
outputFile = args[i + 1];
} else {
if (!args[i - 1].equals("-e") && !args[i - 1].equals("-o")) { inputFile = args[i];
}
} }
String outputStr = "";
ArrayList<String> fileNames = new ArrayList<String>();
if (!needS) {
fileNames.add(inputFile);
} else {
S.s(fileNames);
}
int len = fileNames.size();
String fn; for (int i = 0; i < len; i++) {
fn = fileNames.get(i);
System.out.println(fn);
String fileShortName = fn.substring(fn.lastIndexOf("\\") + 1, fn.length());
Wc wc;
if (needC || needW || needL) {
//统计基本信息
if (needE) {
wc=BasicInfoWithSL.getBasicInfoWithSL(fn,StopList.stopList);
} else {
wc=BasicInfo.basicInfo(fn);
} if (needC) { outputStr += fileShortName;
outputStr += ", 字符数: ";
outputStr += wc.getChars();
outputStr += "\r\n";
}
if (needW) { outputStr += fileShortName;
outputStr += ", 单词数: ";
outputStr += wc.getWords();
outputStr += "\r\n";
}
if (needL) { outputStr += fileShortName;
outputStr += ", 行数: ";
outputStr += wc.getLines();
outputStr += "\r\n";
}
}
if (needA) {
wc = ComInfo.comInfo(fn);//统计复杂信息
//file1.c, 代码行/空行/注释行: 5/2/3
outputStr += fileShortName;
outputStr += ", 代码行/空行/注释行: ";
outputStr += wc.codeLines;
outputStr += "/";
outputStr += wc.empLines;
outputStr += "/";
outputStr += wc.comLines;
outputStr += "\r\n";
} } System.out.println(outputStr);
if (!needO) {
outputFile = "result.txt";
}
try { File writename = new File(outputFile);
writename.createNewFile();
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
out.write(outputStr);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
} } }

Main方法

//基本功能的实现

package wc;

import java.io.*;
/**
* Author: wuhen
* Date: 2018/9/20
* Time: 18:35
*/
public class BasicInfo {
public static Wc basicInfo(String fileName)
{
Wc wc=new Wc();
char charNow;
try
{
File filename = new File(fileName);
InputStreamReader reader = new InputStreamReader(
new FileInputStream(filename));
BufferedReader br = new BufferedReader(reader);
String line ;
line = br.readLine();
boolean partition=true;
while (line != null)
{ wc.chars+=line.length();
wc.lines++; for(int i=0;i<line.length();i++)
{
charNow=line.charAt(i);
if(partition==true&&charNow!='/'&&charNow!='*'&&charNow!='{'&&charNow!='}'&&charNow!='c'&&charNow!='('&&charNow!=')'&&charNow!='\t'&&charNow!=','&&charNow!='.'&&charNow!='?')
{
wc.words++;
}
if(charNow==' '||charNow=='\t'||charNow==','||charNow==',')
{
partition=true;
} }
line = br.readLine();
}
wc.chars+=wc.lines-1;
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
return wc;
}
}

基本功能统计

//扩展功能的实现(停用表)  递归的调用

package wc;

import java.io.*;
/**
* Author: wuhen
* Date: 2018/9/20
* Time: 18:35
*/
public class BasicInfo {
public static Wc basicInfo(String fileName)
{
Wc wc=new Wc();
char charNow;
try
{
File filename = new File(fileName);
InputStreamReader reader = new InputStreamReader(
new FileInputStream(filename));
BufferedReader br = new BufferedReader(reader);
String line ;
line = br.readLine();
boolean partition=true;
while (line != null)
{ wc.chars+=line.length();
wc.lines++; for(int i=0;i<line.length();i++)
{
charNow=line.charAt(i);
if(partition==true&&charNow!='/'&&charNow!='*'&&charNow!='{'&&charNow!='}'&&charNow!='c'&&charNow!='('&&charNow!=')'&&charNow!='\t'&&charNow!=','&&charNow!='.'&&charNow!='?')
{
wc.words++;
}
if(charNow==' '||charNow=='\t'||charNow==','||charNow==',')
{
partition=true;
} }
line = br.readLine();
}
wc.chars+=wc.lines-1;
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
return wc;
}
}

扩展功能

package wc;

import java.io.*;
import java.util.ArrayList; /**
* Author: wuhen
* Date: 2018/10/16
* Time: 9:22
*/
public class StopList {
public static String stopList;
//停用词表
public static void getStopList(ArrayList<String> wordsIgnored)
{ try
{ // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw /* 读入stopList */
File filename = new File(stopList); // 要读取以上路径的input。txt文件
InputStreamReader reader = new InputStreamReader(
new FileInputStream(filename)); // 建立一个输入流对象reader
BufferedReader br = new BufferedReader(reader); // 建立一个对象,它把文件内容转成计算机能读懂的语言
String line ;
line = br.readLine(); String reg1 = " +";
while (line != null)
{
//将读取的行分割成各个单词
String str[] = line.split(reg1); for(int i=0;i<str.length;i++)
{
wordsIgnored.add(str[i]); //将停用词表中的单词放入数组wordsIgnored
}
line = br.readLine(); // 一次读入一行数据
}
br.close();
}
catch (IOException e)
{
e.printStackTrace();
} }
}

stopList

//高级功能,只做了个界面,基本没有实现(时间有限)

//利用了javaFx

//ui,fxml代码(一些简单设计)

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.text.Font?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml"
fx:controller="sample.Controller">
<children>
<CheckBox fx:id="isCountLine" layoutX="97.0" layoutY="49.0" mnemonicParsing="false" selected="false"
text="行数统计"/>
<CheckBox fx:id="isCountChar" layoutX="213.0" layoutY="48.0" mnemonicParsing="false" text="字符统计"/>
<CheckBox fx:id="isCountWord" layoutX="97.0" layoutY="111.0" mnemonicParsing="false" text="单词统计"/>
<CheckBox fx:id="countCodeInfo" layoutX="213.0" layoutY="111.0" mnemonicParsing="false" text="代码行\注释行\空行"/>
<CheckBox fx:id="isRecursion" layoutX="360.0" layoutY="48.0" mnemonicParsing="false" onAction="#changeTextState"
text="递归处理"/>
<Button layoutX="409.0" layoutY="271.0" minHeight="15.999908447265625" mnemonicParsing="false" onAction="#textProcess"
prefHeight="27.0" prefWidth="76.0" text="执行" textAlignment="LEFT"/>
<TextField fx:id="regexField" editable="false" layoutX="447.0" layoutY="44.0" onMouseClicked="#isCheckRecursion"
prefHeight="27.0" prefWidth="108.0" promptText="过滤条件"/>
<TextField fx:id="resultFile" layoutX="176.0" layoutY="273.0" prefHeight="27.0" prefWidth="200.0"
promptText="结果文件(默认result.txt)"/>
<Label layoutX="103.0" layoutY="277.0" text="结果文件:">
<font>
<Font size="14.0" fx:id="x1"/>
</font>
</Label>
<Label font="$x1" layoutX="89.0" layoutY="170.0" text="停止词文件:"/>
<Label ellipsisString="" font="$x1" layoutX="61.0" layoutY="224.0" text="输入文件或目录:" textAlignment="LEFT"
textOverrun="ELLIPSIS" underline="false"/>
<TextField fx:id="stopFile" layoutX="176.0" layoutY="166.0" onMouseClicked="#chooseStopFile" prefHeight="27.0"
prefWidth="200.0" promptText=""/>
<TextField id="stopFile" fx:id="inputFile" layoutX="176.0" layoutY="220.0" onMouseClicked="#chooseInput"
prefHeight="27.0" prefWidth="200.0" promptText=""/>
</children>
</AnchorPane>

ui.fxml

4.测试

1.测试脚本

2.测试效果

3.测试评价

时间有限,高级功能没有实现,但是扩展功能的实现还是可以的,设计到的东西有很多,但是经过研究测试后效果还是不错的。以后有时间继续完成

WordCount 2.0(结对项目)的更多相关文章

  1. WordCount结对项目

    合作者:201631062124,201631062423 代码地址:https://gitee.com/yryx/WordCount 作业地址:https://edu.cnblogs.com/cam ...

  2. 系统分析与设计结对项目——WordCount

    结对项目完成WordCount 合作者:201631062507  201631062526(学号) 代码地址:https://gitee.com/WordCountMC/WordCountTeam ...

  3. 复利计算--结对项目<04-11-2016> 1.0.0 lastest 阶段性完工~

    结对项目:Web复利计算 搭档博客地址:25江志彬  http://www.cnblogs.com/qazwsxedcrfv/ 个人摘要: (2016-04-09-12:00)补充:之前传送门没做好, ...

  4. 软工结对项目之词频统计update

    队友 胡展瑞 031602215 作业页面 GitHub 具体分工 111500206 赵畅:负责WordCount的升级,添加新的命令行参数支持(自定义输入输出文件,权重词频统计,词组统计等所有新功 ...

  5. 高级四则运算器—结对项目反思(193 & 105)

    高级四则运算器—结对项目反思(193 & 105) 本周我和一位韩国同学(71061105)一起结对编程完成了我们的结对项目——高级的小学四则运算题目生成器. PSP表格   PSP2.1 P ...

  6. 高级四则运算器—结对项目总结(193 &105)

    高级四则运算器—结对项目总结 为了将感想与项目经验体会分割一下,特在此新开一篇博文. 界面设计 啥都不说,先上图震慑一下... 上面的三个界面是我们本次结对项目的主界面,恩,我也觉得挺漂亮的!你问我界 ...

  7. 高级软件工程2017第3次作业——结对项目:四则运算题目生成程序(基于GUI)

    Deadline:2017-10-11(周三)21:00pm (注:以下内容参考集大作业 ) 前言 想过和别人一起探索世界吗?多么希望,遇到困难时,有人能一起探讨:想要懈怠时,有人推你一把:当你专注于 ...

  8. 2018-2019-2 《Java程序设计》结对项目阶段总结《四则运算——整数》(二)

    20175218 2018-2019-2 <Java程序设计>结对项目阶段总结<四则运算--整数> 一.需求分析 实现一个命令行程序,要求: 自动生成小学四则运算题目(加,减, ...

  9. 结对项目——四则运算GUI项目

    一.项目地址:https://git.coding.net/lvgx/wsz.git 二.PSP: PSP2.1 任务内容 计划共完成需要的时间(min) 实际完成需要的时间(min) Plannin ...

随机推荐

  1. layui内置loading等待加载

    点击功能按钮之后 var loading = layer.load(0, { shade: false, time: 2*1000 }); 参数: icon:0,1,2 loading风格 shade ...

  2. linux mount命令详解(iso文件挂载)

    挂载命令:   mount [-t vfstype] [-o options] device dir   mount 是挂载命令 -t + 类型 -o + 属性 device iso的文件 dir 挂 ...

  3. 浅窥ArcGIS Data Store之两斑

    关于 ArcGIS Data Store,我们备受大家喜爱的suwenjiang朋友在其博客空间suwenjiang的烂笔头中贡献了<ArcGIS Data Store初体验>一文,全面讲 ...

  4. JAVA加密解密DES对称加密算法

    下面用DES对称加密算法(设定一个密钥,然后对所有的数据进行加密)来简单举个例子. 首先,生成一个密钥KEY. 我把它保存到key.txt中.这个文件就象是一把钥匙.谁拥有它,谁就能解开我们的类文件. ...

  5. Python3+Selenium3+webdriver学习笔记7(选择多链接的结果、iframe、下拉框)

    #!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...

  6. VC++堆栈大小设置

    VC++堆栈默认大小是1M,如果你分配大于1M的堆,一般会出异常,这里你要把堆调大些,下面是VC++6.0与VC++2010的设置方法 VC++6.0: 工程==>设置==>“连接”界面, ...

  7. 【Python图像特征的音乐序列生成】如何标记照片的特征

    目前我能想到的办法是这样的: 1,提取照片中的实体特征,借用某个pre-trained model进行tag标记. 2,将特征组合起来,形成一个bag-of-word model,然后将这个向量作为输 ...

  8. Cause: java.lang.UnsupportedOperationException

    运行web项目的时候出现以下错误: ### Cause: java.lang.UnsupportedOperationException    at org.mybatis.spring.MyBati ...

  9. 在一个另一个文件中 #include一个**dlg.h文件,会发生dlg的资源ID未定义的错误 :

    1    在一个另一个文件中 #include一个**dlg.h文件,会发生dlg的资源ID未定义的错误 : dlg1.h(23) : error C2065: 'IDD_DIALOG1' : und ...

  10. acid (数据库事务正确执行的四个基本要素的缩写)

    ACID,指数据库事务正确执行的四个基本要素的缩写.包含:原子性(Atomicity).一致性(Consistency).隔离性(Isolation).持久性(Durability).一个支持事务(T ...