课程设计总结报告模板.docx
《课程设计总结报告模板.docx》由会员分享,可在线阅读,更多相关《课程设计总结报告模板.docx(26页珍藏版)》请在冰豆网上搜索。
课程设计总结报告模板
课程编号:
B080109010
数据结构课程设计
总结报告
姓名
学号
班级
指导教师
姜琳颖
实验名称
数据结构课程设计
开设学期
2017-2018第一学期
开设时间
第1周——第3周
报告日期
2017年9月12日
评定成绩
评定人
评定日期
2017-9-25
东北大学软件学院
第一章需求分析
。
1、问题的定义
设计一个景点管理系统,分为管理员和游客两部分,需要帮助景区更为方便的管理景区,规划道路,帮助游客更为方便地找到自己想要的信息
2、问题分析
为游客提供景点分布图,景点简介,景点查询,以及查询路线选择等相关建议;为管理员提供添加景点,删除景点,添加道路,以及发布公告的功能,考虑到景区的实际情景,整个项目应该设计为一个手机App,这样才能满足用户需求,方便用户操作
3、研究意义
这是一个与实际相连的小项目,以方便游客游览和景区管理作为最终目的,提供高效的算法,和简洁的界面,方便用户操作,这样有利于学生写的作业与社会实际情况相连,考虑确实需求
第二章系统设计
2.1总体设计
(1)基本数据结构:
list:
MyList
privatefinalstaticintINIT_CAPACITY;
privateObject[]mList;
privateintmCurrentCapacity;
privateintmSize;
publicvoidadd(Titem);
publicvoidremove(intindex);
publicTget(intindex);
publicvoidset(intindex,Titem);
publicintsize();
队列:
MyQueue
privateObject[]queue;
privateintfront;
privateintnItems;
privateintmaxSize=100;
publicvoidadd(Titem)
publicTremove()
publicbooleanisEmpty()
publicintsize()
栈:
MyStack
privateintcapacity=10;
privateintlength=0;
privateObject[]stack;
publicbooleanisEmpty()
publicbooleanisFull()
publicvoidpush(Objectobj)
publicTpop()
publicintsize()
邻接表:
Graph
publicMyListadjList;
publicMyListvisit;
边:
EdgeNode
publicintindex;
publicStringname;
publicbooleanflag=true;
publicintvalue;
publicEdgeNodenextArc;
点:
VertexNode
publicStringname;
publicAttractionattraction;
publicEdgeNodefirstArc=newEdgeNode();
(2)游客操作的定义:
提供所有景点之间的距离:
voidoutputGraph()
搜索相关的景点:
ArrayListfindByName(Stringkeyword)
通过欢迎度来排序:
ArrayListsortByPopular()
通过岔路数进行排序:
ArrayListsortByStreetNum()
找最短路径的长度:
intshortestDistance(Stringstart,Stringend)
找最短路:
StringshortestRoute(StringStart,Stringend)
获取所有景点:
ArrayListgetAllAttraction()
获取所有的道路:
ArrayListgetAllStreet()
提供导游回路:
Stringoutputloop()
登记车辆:
StringregisterCar(Stringlicense)
驶出车辆:
StringleaveCar(Stringlisence)
(3)管理员操作定义:
添加新景点:
voidaddAtrraction(VertexNodenewAttraction)
添加道路:
StringaddStreet(Stringstart,Stringend,intdistance)
删除景点:
booleandeletAttraction(Stringname)
维护道路:
voidmaintainStreet(Stringstart,Stringend)
发布公告:
voidsendNotice()
2.2程序设计
(1)Dijkstra算法找最短路径
初始时,S只包含了初始的起点,即S={v},v的距离为0。
U包含着v之外的所有节点,即U={其余节点},若v与U中顶点有边,则正常有权值,若不是u与v无直接的边相接,则的权值为无穷大。
从U中选取一个距离v最小的顶点k,把k,加入S中。
以k为新考虑的中间点,修改U中各顶点的距离,若从源点v到顶点u的距离(经过顶点k)比原来距离(不经过顶点k)短,则修改顶点u的距离值,修改后的距离值为顶点k的距离加上边上的权。
重复步骤2和3直到所有顶点都包含在S中
(2)哈密尔顿回路找最短的导游回路
初始时,S中只包含一个起点,即S={v}
遍历所有与v,相邻的节点,选取最近的顶点k加入,检查集合中是否形成了回路,若存在,则换其他点,若没有,则k便成了新的v节点
重复步骤2,直到将所有节点都包含在S中
第三章系统实现与调试
3.1景区路线图的初始化
我将所需要的数据放进了数据库,然后再录入数据,通过Graph,VertexNode和EdgeNode三个数据结构来保存这个邻接表
while(rs.next()){//初始各顶点信息
Stringname=rs.getString("name");
Stringintroduce=rs.getString("introduce");
intpopularity=rs.getInt("popularity");
intstreetNum=rs.getInt("streetnum");
G.adjList.add(newVertexNode(name,newAttraction(name,introduce,popularity,streetNum)));
G.adjList.get(i).firstArc=null;
G.visit.add(false);
i++;
}
v=G.adjList.size();//初始化顶点数目的信息
sql="select*fromroute";
stmt=conn.prepareStatement(sql);
rs=stmt.executeQuery();
i=0;
while(rs.next()){//根据路径形成图
Stringstart=rs.getString("start");
Stringend=rs.getString("end");
intv1=Index(start);
intv2=Index(end);
EdgeNodeenode1=newEdgeNode();
enode1.name=start;
enode1.index=v1;
enode1.value=rs.getInt("distance");
enode1.nextArc=G.adjList.get(v2).firstArc;
G.adjList.get(v2).firstArc=enode1;
EdgeNodeenode2=newEdgeNode();
enode2.name=end;
enode2.index=v2;
enode2.value=rs.getInt("distance");
enode2.nextArc=G.adjList.get(v1).firstArc;
G.adjList.get(v1).firstArc=enode2;
}
3.2景区管理模块
(1)添加景点
publicvoidaddAtrraction(VertexNodenewAttraction){
//添加新景点
G.adjList.add(newAttraction);
v=G.adjList.size();
}
(2)删除景点
enode=newEdgeNode();
enode=G.adjList.get(v).firstArc;
while(enode!
=null){
EdgeNodepEnode=newEdgeNode();
EdgeNodebEnode=newEdgeNode();
pEnode=G.adjList.get(enode.index).firstArc;
bEnode=G.adjList.get(enode.index).firstArc;
if(pEnode.index==v){
G.adjList.get(enode.index).firstArc=pEnode.nextArc;
}else{
pEnode=pEnode.nextArc;
}
while(pEnode!
=null){
if(pEnode.index==v){
bEnode.nextArc=pEnode.nextArc;
break;
}
pEnode=pEnode.nextArc;
}
enode=enode.nextArc;
}
G.adjList.remove(v);
(3)添加道路
intv1=Index(start);
intv2=Index(end);
EdgeNodeenode1=newEdgeNode();
enode1.name=start;
enode1.index=v1;
enode1.value=distance;
enode1.nextArc=G.adjList.get(v2).firstArc;
G.adjList.get(v2).firstArc=enode1;
EdgeNodeenode2=newEdgeNode();
enode2.name=end;
enode2.index=v2;
enode2.value=distance;
enode2.nextArc=G.adjList.get(v1).firstArc;
G.adjList.get(v1).firstArc=enode2;
3.3景点的查找与排序
(1)景点的查找
publicArrayListfindByName(Stringkeyword){
//搜索相关的景点
ArrayListresult=newArrayList();
ArrayListattractions=getAllAttraction();
for(inti=0;iif(attractions.get(i).name.indexOf(keyword)>=0||attractions.get(i).introduce.indexOf(keyword)>=0){
result.add(attractions.get(i));
}
}
returnresult;
}
(2)景点排序
publicArrayListsortByPopular(){
//通过欢迎度来排序
ArrayListattractions=getAllAttraction();
for(inti=0;ifor(intj=i+1;jif(attractions.get(i).popularityAttractiontemp=attractions.get(i);
attractions.set(i,attractions.get(j));
attractions.set(j,temp);
}
}
}
returnattractions;
}
3.4两景点间最短路径
(1)得到最短路径的长度
EdgeNodeenode=G.adjList.get(x).firstArc;
//初始化distance
while(enode!
=null){
distance[enode.index]=enode.value;
enode=enode.nextArc;
}
for(intk=1;kintsecond=inf;
intpIndex=x;
//选取用于松弛的点
for(inti=0;iif(!
(G.visit.get(i))&&distance[i]pIndex=i;
second=distance[i];
}
}
G.visit.set(pIndex,true);
EdgeNodeenode1=G.adjList.get(pIndex).firstArc;
for(inti=0;iif(!
(G.visit.get(i))){
inttemp=inf;
enode1=G.adjList.get(pIndex).firstArc;
while(enode1!
=null){
if(enode1.index==i){
temp=enode1.value;
break;
}
enode1=enode1.nextArc;
}
if(distance[i]>(distance[pIndex]+temp)){
distance[i]=distance[pIndex]+temp;
}
}
}
}
returndistance[Index(end)];
(2)得到最短路径
publicStringshortestRoute(Stringstart,Stringend){
int[]distance=newint[v+1];
int[][]p=newint[v+1][v+1];
//初始化distance
for(inti=0;idistance[i]=inf;
}
for(inti=0;ifor(intj=0;jp[i][j]=-1;
}
}
//初始化visit的值
for(inti=0;iG.visit.set(i,false);
}
intx=Index(start);
distance[x]=0;
G.visit.set(x,true);
EdgeNodeenode=G.adjList.get(x).firstArc;
//初始化distance
while(enode!
=null){
distance[enode.index]=enode.value;
//若存在直接路径
p[enode.index][0]=x;
p[enode.index][1]=enode.index;
enode=enode.nextArc;
}
for(intk=1;kintsecond=inf;
intpIndex=x;
//选取用于松弛的点
for(inti=0;iif(!
(G.visit.get(i))&&distance[i]pIndex=i;
second=distance[i];
}
}
G.visit.set(pIndex,true);
EdgeNodeenode1=G.adjList.get(pIndex).firstArc;
for(inti=0;iif(!
(G.visit.get(i))){
inttemp=inf;
enode1=G.adjList.get(pIndex).firstArc;
while(enode1!
=null){
if(enode1.index==i){
temp=enode1.value;
break;
}
enode1=enode1.nextArc;
}
if(distance[i]>(distance[pIndex]+temp)){
distance[i]=distance[pIndex]+temp;
for(intj=0;jp[i][j]=p[pIndex][j];
if(p[i][j]==-1){//在p[w][]第一个等于-1的地方加上顶点w
p[i][j]=i;
break;
}
}
}
}
}
}
intpEnd=Index(end);
Stringroute="";
//最短路径
for(inti=0;iif(p[pEnd][i]>-1){
route+=G.adjList.get(p[pEnd][i]).name;
if(i+1==v||p[pEnd][i+1]==-1){
break;
}else{
route+="->";
}
}
}
returnroute;
}
(3)导游线路图设计
publicStringoutputloop(){
//提供导游回路
boolean[]visit=newboolean[v+1];
for(inti=0;ivisit[i]=false;
}
intstart=0;//先假定从第一个值开始
int[]result=newint[v+1];
EdgeNodeenode=newEdgeNode();
intnext=start;
visit[start]=true;
intk=0;
intvalue=inf;
while(next!
=-1){
enode=G.adjList.get(next).firstArc;
result[k++]=next;
next=-1;
value=inf;
while(enode!
=null){
if(!
visit[enode.index]&&enode.valuenext=enode.index;
value=enode.value;
}
enode=enode.nextArc;
}
if(next!
=-1){
visit[next]=true;
}
}
Stringans="";
for(inti=0;ians+=G.adjList.get(result[i]).name;
if(i!
=v-1){
ans+="->";
}
}
returnans;
}
3.6输出车辆的进出信息
(1)车辆登记
publicStringregisterCar(S