02个人作业

作业内容:

撰写一篇博客要求讲述的设计思想,源程序代码、运行结果截图、编程总结分析,并按照PSP0级的要求记录开发过程中的时间记录日志。

源代码贴在最后,本博客只展示web端,因为app端主要由我的队友崔建铭来编写,所以app端代码在他的博客上展示。


一、项目概述
北京地铁查询系统是一个方便乘客查询地铁信息的应用,通过地铁站名、地铁号码、起终点站等参数来查询地铁路线和地铁站信息。系统提供了多种查询方式和查询结果展示,方便用户快速查询地铁信息,并能够查看地铁线路图和地铁站周边信息。
二、设计思路和功能点

开发环境和技术栈选择

我们选择Java EE作为开发环境,MySQL数据库作为数据存储。前端技术方面,我们使用HTML/CSS/JS来构建网页界面。

设计思路和功能点

按地铁站名查询功能:用户可以输入地铁站名进行查询,系统返回包括该站点所属的所有线路、出入口数量、周边设施以及公交换乘等信息。
按地铁号查询功能:用户可以输入地铁号进行查找,系统返回该地铁线路的所属站点、首末班车时间、票价等详细信息。
按起终点站查询最短路径功能:用户可以输入出发站和目的站进行查询。系统会根据用户提供的信息返回包括最短路线、步行距离、总计站数、票价等详细信息。
查看地图功能:用户可以查看地铁线路图和地铁站位置图,并且可以实时定位当前所在位置以及周边各种设施信息,并支持地铁站点和线路搜索。
三、编程总结和分析
在开发过程中,我们遇到了很多问题,主要是对开发环境、框架的理解和熟悉程度的差距,以及系统的数据量和多功能性带来的处理复杂度。我们采用了反复调试和优化代码的方式,不断增强代码的可读性和性能,提升了系统的处理效率和用户体验。
总的来说,北京地铁查询系统涵盖了许多功能和信息,系统的展示方式也非常直观。同时,我们也对当前开发过程中所遭遇的问题和解决方法进行了总结和记录,希望对其他开发者有所帮助。
四、时间记录日志
| 任务 | 计划用时 | 实际用时 |
| --- | --- | --- |
| 系统分析和设计 | 20h | 18h |
| 技术研究和环境搭建 | 10h | 12h |
| 数据库设计和模块开发 | 40h | 45h |
| 系统测试和相关文档撰写 | 20h | 25h |
| 系统优化和性能调节 | 10h | 10h |
以上是我在项目开发期间的时间记录日志。总计计划100小时,实际用时110小时。其中,遭遇的主要问题出现在系统分析和设计阶段,这个阶段需要准确掌握功能和细节,所以需要更多的工作时间。在系统测试和文档撰写方面,花费时间比预计的要多,由于我们需要确保系统的稳定性和完整性。通过时间记录日志,我们可以更加直观地感受到整个项目的开发过程,并且可以对之后的工作量进行精细化管理和调整。

源代码:web端

dao:

package dao;

import DBUtil.DBUtil;
import bean.Bean;
import org.testng.annotations.Test;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class Dao {//dao层
private DBUtil dbutil = new DBUtil();

public Dao() {
// TODO Auto-generated constructor stub
}

@Test
public List<Bean> list1() {//查询所有方法
String sql = "select * from list1";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

public List<Bean> list2() {//查询所有方法
String sql = "select * from list2";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

public List<Bean> list3() {//查询所有方法
String sql = "select * from list3";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

public List<Bean> list4() {//查询所有方法
String sql = "select * from list4";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

public List<Bean> list5() {//查询所有方法
String sql = "select * from list5";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

public List<Bean> list6() {
String sql = "select * from list6";
Connection conn = DBUtil.getConnection();
Statement st = null;
List<Bean> list = new ArrayList<>();
ResultSet rs = null;
Bean bean = null;
try {
st = conn.createStatement();
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {

int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
bean = new Bean(listid, listname, id, zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, st, conn);
}
return list;
}

/*public List<Bean> searchlistname(String name){
String sql="select * from allstation where zname= ?";
Connection conn=DBUtil.getConnection();
Statement st=null;
List<Bean> list=new ArrayList<>();
ResultSet rs=null;
Bean bean=null;
pa.setString(1,name );
try {
st=conn.createStatement();
st.executeQuery(sql);
rs=st.executeQuery(sql);
while(rs.next()) {
int listid=rs.getInt("listid");
String listname = rs.getString("listname");
int id=rs.getInt("id");
String zname = rs.getString("zname");
bean=new Bean(listid,listname,id,zname);
list.add(bean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
DBUtil.close(rs, st, conn);
}
return list;
}

/* public String searchlistname(String name) throws ClassNotFoundException, SQLException {

Connection conn = DBUtil.getConnection();
Statement state = null;
ResultSet rs = null;
String listname = null;
try {
String sql1 = "select listname from allstation where zname ='" + name + "' ";
state = conn.createStatement();
rs = state.executeQuery(sql1);
while (rs.next()) {
listname = rs.getString("listname");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return listname;

}*/
public List<Bean> searchlistname(String s1) {
List<Bean> list=new ArrayList<Bean>();
Connection con;
try {
String sql="select * from allstation where zname = ?";
con = DBUtil.getConnection();
PreparedStatement pa=con.prepareStatement(sql);
pa.setString(1,s1);
ResultSet rs=pa.executeQuery();
while(rs.next()) {
Bean L = new Bean();
int listid = rs.getInt("listid");
String listname = rs.getString("listname");
int id = rs.getInt("id");
String zname = rs.getString("zname");
L=new Bean(listid,listname,id,zname);
list.add(L);

}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
}

index.html
<!doctype html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta name = "viewport"
content = "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<title>Test</title>
<script src = "js/jquery-3.6.0.js"></script>
<style>
/*兼容浏览器*/
* {
margin: 0;
padding: 0;
}

.content {
width: 100%;
height: 100%;
}

.content-left {
width: 19%;
height: 800px;
background-color: #1c232f;
float: left;
}

.content-right {
width: 81%;
height: 800px;
background-color: #6495ED;
float: left;
}

.left-title {
width: 100%;
height: 50px;
}

.left-title > a {
display: block;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
color: white;
/*去掉a下默认下划线*/
text-decoration: none;
}

/*分割线*/
.seg {
height: 1px;
width: 100%;
background-color: black;
}

.nav {
/*上下5,左右0*/
margin: 5px 0;
}

/*菜单项主标题*/
.nav-title {
height: 40px;
width: 100%;
color: white;
text-align: center;
line-height: 40px;
cursor: pointer;
}

/*子标题内容区*/
.nav-content {
width: 100%;
height: 100%;
background-color: #0C1119;
}

/*子标题的样式*/
.nav-content > a {
display: block;
width: 100%;
height: 30px;
color: #CCCCCC;
text-decoration: none;
text-align: center;
line-height: 30px;
font-size: 13px;
}

/*子标题鼠标经过时的改变颜色*/
.nav-content > a:hover {
color: #FFFFFF;
background-color: #12040c;
}

/*内容区*/
.content-right{
font-size: 50px;
line-height: 600px;
text-align: center;
}
</style>

<script src = "https://code.jquery.com/jquery-3.2.1.min.js"
integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin = "anonymous"></script>

<script>
$(function () {

//隐藏所有子标题
$(".nav-menu").each(function () {
$(this).children(".nav-content").hide();
});

//给菜单项中的所有主标题绑定事件
$(".nav-title").each(function () {
//获取点击当前标签下所有子标签
var navConEle = $(this).parents(".nav-menu").children(".nav-content");

//绑定点击事件,判断navConEle的display这个属性是否为none,时none的话时隐藏状态
$(this).click(function(){
if (navConEle.css("display") !== "none") {
//隐藏,传参数自带动画,单位为毫秒
navConEle.hide(300);
} else {
//显示,传参数自带动画,单位为毫秒
$(".nav-menu").each(function () {
$(this).children(".nav-content").hide(300);
});
navConEle.show(300);
}
});
});

$(".nav-content>a").each(
function () {
$(this).click(
function () {
$(".content-right").html($((this).name).html());
});
}
);

});

</script>
</head>
<body>
<div class = "content">
<!--左侧导航栏-->
<div class = "content-left">
<div class = "left-title">
<a href = "right.html" target="right">北京地铁</a>
</div>

<!--水平线-->
<div class = "seg"></div>

<!--菜单栏导航-->
<div class = "nav">
<!--每一个菜单栏项-->
<div class = "nav-menu">
<!--主标题-->
<div class = "nav-title">地铁线路查询</div>
<!--子标题-->
<div class = "nav-content">
<a href = "chaxun2.html" target="right">查询站点</a>
<a href = "chaxun.html" target="right">查询线路</a>
</div>
</div>

<!--每一个菜单栏项-->
<div class = "nav-menu">
<!--主标题-->
<div class = "nav-title">换乘相关</div>
<!--子标题-->
<div class = "nav-content">
<a href="chaxun3.html" target="right" >查询起终点</a>
<a href = "changestop.html" target="right">查询换乘</a>
</div>
</div>

<!--每一个菜单栏项-->
<div class = "nav-menu">
<!--主标题-->
<div class = "nav-title">地图查看</div>
<!--子标题-->
<div class = "nav-content">
<a href = "map.html" target="right" >查看北京地铁地图</a>
</div>
</div>
</div>

<!--水平线-->
<div class = "seg"></div>
</div>

<!--右侧内容区-->
<div class = "content-right">
<iframe height="100%" name="right" src="right.html" width="100%" ></iframe>
</div>



</div>
</body>
</html>

list2.jsp:

<%--
Created by IntelliJ IDEA.
User: xielumeng
Date: 2023/3/20
Time: 10:05
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
Object message = request.getAttribute("message");
Object grade_list = request.getAttribute("grade_list");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 >查询站点</h1>
<a href="index.html">返回主页</a>
<table >
<tr>
<td>线路名</td>
</tr>
<c:forEach items="${list}" var="item">
<tr>
<td>${item.listname}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>


chaxun.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>线路查询</title>
<script src = "js/jquery-3.6.0.js"></script>
<style >
a{
display: block;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
color: white;
/*去掉a下默认下划线*/
text-decoration: none;
}
</style>
</head>
<body>
<div align = "center"> <a href="servlet?method=list1" > 一号线</a></div><br>
<div align = "center"> <a href="servlet?method=list2" > 二号线</a></div><br>
<div align = "center"> <a href="servlet?method=list3" > 三号线</a></div><br>
<div align = "center"> <a href="servlet?method=list4" > 四号线</a></div><br>
<div align = "center"> <a href="servlet?method=list5" > 五号线</a></div><br>
<div align = "center"> <a href="servlet?method=list6" > 六号线</a></div><br>

</body>
</html>

chaxun2.html:
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<head>
<title>站点查询</title>
</head>
<body>
<h1>站点查询</h1>
<form action="servlet?method=search" method="post">
请输入站点:<input type="text" size="15" name="s1" ><br>
<input type="submit" value="查询">
</form>
</body>
</html>

chaxun3.jsp:
<!DOCTYPE html>

<head>
<meta charset="UTF-8">
<title>起点-终点查询</title>
</head>
<body>
<h1>起点-终点查询</h1>
<form action="servlet?" method="post">
请输入起点:<input type="text" size="15"><br>
请输入终点:<input type="text" size="15"><br>
<input type="submit" value="提交">
</form>

</body>
</html>


posted @ 2023-03-21 22:01  XieLumeng  阅读(18)  评论(0编辑  收藏  举报