项目:地铁收费系统 计应192西第五组 蔡瑜晶

需求分析:从收费的起点到终点收费系统                                                 时间:3minutes

设计文档:3个label 2个button 1个comboBox                                               时间:5minutes

设计复审:李娟娟复审                                                                             时间:20minutes                                       

代码规范:使用驼峰式命名                    时间:3minutes                                      

具体设计: 输入两个数字得出正确的结果             时间 2minutes

具体编码如下:                                                                                      时间:1.5taday

窗体界面:         

 static int getNum(String name)

 {String sql = "select xianluhao from aaa where name ='" + name + "'";Connection conn = DBUtil.getConn()

;Statement state = null;

ResultSet rs = null;int number=0;

rs = state.executeQuery(sql);

while (rs.next()) {number = rs.getInt("xianluhao");}} catch (Exception e) {e.printStackTrace();}

finally {DBUtil.close(rs, state, conn);}

return number;}

public static int getZhanhao(String name) {String sql = "select num from aaa where name ='" + name + "'";Connection conn = DBUtil.

getConn();Statement state = null;

ResultSet rs = null;int zhanhao=0;

return zhanhao;}

public static String getLine1(int zhanhao1,int zhanhao2)

{String line="";String sql = "select name from aaa where num between '"+zhanhao1+"' and '"+zhanhao2+"'order by num ASC ";

Connection conn = DBUtil.getConn();

Statement state = null;

ResultSet rs = null;try {state = conn.createStatement();

rs = state.executeQuery(sql);

if(rs.next())line=rs.getString("name");

while (rs.next()) {String name=rs.getString("name");

line=line+"->"+name;}     }

catch (Exception e) {e.printStackTrace();

}

return line;}

public static String getLine2(int zhanhao1,int zhanhao2)

 {

String line="";String sql = "select name from aaa where num between '"+zhanhao1+"' and '"+zhanhao2+"'  order by num DESC ";

Connection conn = DBUtil.getConn();

Statement state = null;ResultSet rs = null;

rs = state.executeQuery(sql);

if(rs.next())line=rs.getString("name");while

(rs.next()){String name=rs.getString("name");line=line+"->"+name;

}     } {e.printStackTrace();     }   

}return line;}}  

package servlet;

if ("chaxun".equals(method)) {chaxun(req, resp);} }

private void chaxun(HttpServletRequest req, HttpServletResponse resp) throws ServletException,  String zhong=req.getParameter("zhong");

int zhanhao1=dao.getZhanhao(qi);

 int zhanhao2=dao.getZhanhao(zhong);

 int number1=dao.getNum(qi);

 int number2=dao.getNum(zhong);

if(number1==number2)

{if(zhanhao1<zhanhao2){Stringline=dao.getLine1(zhanhao1, zhanhao2);req.setAttribute("line",line );

req.setAttribute("num",number1);

req.getRequestDispatcher("list.jsp").forward(req,resp);

}

if(zhanhao1>zhanhao2){String line=dao.getLine2(zhanhao2, zhanhao1);

System.out.r("list.jsp").forward(req,resp);}}}} 

print(line);req.setAttribute("num",number1);req.setAttribute("line",line );req.getRequestDispatche

 窗口界面:项目总结分析:这个项目因为涉及到一个最短路径的问题。

 

代码复审:在头脑里过一遍代码                       时间:3minutes

测试:弹出的页面执行结果正确                      时间:2minutes

测试报告:没有问题功能实现                        时间:1minutes

计算工作量:                                                时间:2taday

总结:多动手是可以快速找出自己的问题所在

上一篇:四则运算--计应192--琚江涛


下一篇:Centos 7 安装MySQL 5.7 并修改默认路径