201621044079韩烨软件工程作业三

软件工程 作业三


1.要求地址


2.PSP表格

PSP2.1 个人开发流程 预估耗费时间(分钟) 实际耗费时间(分钟)
Planning 计划 5 3
· Estimate 明确需求和其他相关因素,估计每个阶段的时间成本 5 3
Development 开发 274 308
· Analysis 需求分析 (包括学习新技术) 60 60
· Design Spec 生成设计文档 5 2
· Design Review 设计复审 4 2
· Coding Standard 代码规范 5 5
· Design 具体设计 10 20
· Coding 具体编码 120 180
· Code Review 代码复审 10 9
· Test 测试(自我测试,修改代码,提交修改) 60 30
Reporting 报告 40 65
· 测试报告 30 60
· 计算工作量 5 2
· 并提出过程改进计划 3 3

3.解题思路描述

这次项目主要是建立在上一个项目的基础上,经过讨论,最后我实现的部分是web版本的GUI界面实现。

对于web版本,首先实现了两个前端jsp页面,一个界面使用表单,以及文本框,按钮等表单控件来获取布局,通过文本框提交按钮,将文件文本框中的内容提交到处理的jsp界面,然后根据选择的按钮调用后台函数进行相应的处理。然后在结果文本框中显示得到的答案。


4.代码说明

1.表单内容

该内容使用了表单,设置了两个文本框,一个文本框用于接受文件的输入,另外一个用于实现统计结果的输出,然后设置了若干个按钮进行数据的处理。

        <div id="div">
            <form action="show.jsp" method="post" class="filech" id="filech" name="filech">
            <fieldset class="filefield">
                <legend>请选择一个文件:</legend>

                <input type="input" name="file" placeholder="请在此输入文件路径" >
                <input type="hidden" value="" name="ch">
                <input type="submit" value="上传" id="1" name="1" onclick= "ch.value= '上传' " onchange="selectxt(this)">
            </fieldset>
            <fieldset class="textfield">
                <textarea  id="textarea" placeholder="请点击上面按钮选择文件或直接在此输入文本" name="textarea"></textarea>
            </fieldset>
            
        </form>
        
        <textarea class="dealtext" id="result" readonly ></textarea>

        </div>
        <div class="but">
        <input type="submit" form="filech" value="详细统计" id="2" name="2" onclick= "ch.value= '详细统计' "/>
        <input type="submit" form="filech" value="字符统计" id="3" name="3" onclick= "ch.value= '字符统计' "/>
        
        <input type="submit" form="filech" value="行数统计" id="4" name="4" onclick= "ch.value= '行数统计' "/>
        <input
            type="submit" form="filech" value="单词统计" 
            onclick="ch.value= '单词统计' " />
        <input type="submit" form="filech" value="词频统计" id="5" name="5" onclick= "ch.value= '词频统计' "/>
        <input type="number" form="filech" placeholder="请输入词组数量" name="group" />
        <input type="submit" form="filech" value="词组统计" id="6" onclick= "ch.value= '词组统计' " />
        </div>

2.文件处理部分代码

该部分是实现文件的上传,并将文件内容写入相应的位置。

            <%
                String text = "";
                String ch = request.getParameter("ch");
                if (ch.equals("上传")) {
                    try {
                        String getfile = request.getParameter("file");
                        if (!getfile.substring(getfile.length() - 3, getfile.length()).equals("txt"))
                            throw new Exception();
                        File file = new File(getfile);
                        FileDeal fd = new FileDeal();
                        text = fd.FileToString(file);
                    
            %>
            <fieldset class="textfield">
                <textarea id="textarea" placeholder="请点击上面按钮选择文件或直接在此输入文本"
                    name="textarea"><%=text%></textarea>
            </fieldset>
        </form>

        <textarea class="dealtext" id="result" readonly></textarea>
        <%
            } catch (Exception e) {
            }
        %>

3.功能函数部分代码

这一部分是调用Java函数,来实现相应的功能。

        <textarea class="dealtext" id="result" readonly></textarea>
        <%
            if (ch.equals("详细统计")) {
                String t = request.getParameter("textarea");
                WordDeal wd = new WordDeal(t);
                int charnum = wd.getCharCount();
                int wordcount = wd.getWordCount();
                int line = wd.getLineCount();
                Map<String, Integer> wc = wd.getWordFreq();//词频统计
                List list = wd.sortMap(wc);
                String[] wFreq = wd.ListToArray2(list);
        %>
        <fieldset class="textfield">
            <textarea id="textarea" placeholder="请点击上面按钮选择文件或直接在此输入文本"
                name="textarea"><%=t%></textarea>
        </fieldset>
        </form>

        <textarea class="dealtext" id="result" readonly>字符数为:<%=charnum%>

单词数为:<%=wordcount%>

有效行数为:<%=line%>

词频数:
<%for (int i = 0; i < wFreq.length; i++) {%>
<%=wFreq[i]%>
<%}%></textarea>

5.结对心得

结对编程可以很大程度上提高编程的效率 对于设计思路的共享我觉得是有很大作用的 尤其是相互之间的错误 有一些很简单但是自己确实很难发现但是队友就是很容易帮你找出来 讨论出来的东西也更加全面效率更高

猜你喜欢

转载自www.cnblogs.com/HYSOUL/p/9751062.html