IT计算机全国交通咨询模拟数据结构Jaa课程设计

上传人:工**** 文档编号:496297166 上传时间:2024-03-17 格式:DOC 页数:46 大小:398.50KB
返回 下载 相关 举报
IT计算机全国交通咨询模拟数据结构Jaa课程设计_第1页
第1页 / 共46页
IT计算机全国交通咨询模拟数据结构Jaa课程设计_第2页
第2页 / 共46页
IT计算机全国交通咨询模拟数据结构Jaa课程设计_第3页
第3页 / 共46页
IT计算机全国交通咨询模拟数据结构Jaa课程设计_第4页
第4页 / 共46页
IT计算机全国交通咨询模拟数据结构Jaa课程设计_第5页
第5页 / 共46页
点击查看更多>>
资源描述

《IT计算机全国交通咨询模拟数据结构Jaa课程设计》由会员分享,可在线阅读,更多相关《IT计算机全国交通咨询模拟数据结构Jaa课程设计(46页珍藏版)》请在金锄头文库上搜索。

1、数据结构课程设计报告全国交通咨询模拟 学院(系): 计算机科学与工程学院 班 级: 学生姓名: 学号 指导教师: 时间: 从2011年12月19日 到2011年12月23日一、课程设计概述:使用语言: java编译环境:java虚拟机二、课程设计题目一实验内容全国交通咨询模拟问题描述1、 管理员可以添加、修改、删除各交通路线信息。2、 用户查询从某一地点到另一地点的信息,提供查询转车次数最少、花费最少、所用时间最少的相关信息。需求分析1、 管理员和用户拥有不同的操作界面。管理员从键盘输入个交通路线并保存在trainInformation.txt中。2、 对文件trainInformation.

2、txt中的数据进行处理,要求具有如下功能:、 城市信息进行编辑。、 对列车时刻表进行编辑(增设或删除)的功能。、 提供三种最优决策:最省钱到达,转车最少。、 提供各列车详细信息。3、 界面美观概要设计class MoneyLeast/求出两站点花费最少的路径class TrainContral/从文件中读出列车的所有信息或者将列车的信息写入到文件class TrainGraph/列车航线交通图class AdmFrame/管理员登陆界面class SearchInFrame/用户查询信息和显示信息界面 存储结构class City/城市存储private String cityName;cla

3、ss Train /列车存储 private String trainID; private City startCity; private City endCity; private Date startDate; private Date endDate;private int money; 详细设计- City-/* * 城市的对象 * 城市有城市名 * 实现序列化 * 重写equals方法和toString方法 */package com.consel;import java.io.Serializable;/实现序列化的接口public class City implements S

4、erializable private static final long serialVersionUID = 5612649006026227701L; private String cityName; public City(String cityName) this.cityName = cityName; public String getCityName() return cityName; public void setCityName(String cityName) this.cityName = cityName; Override public String toStri

5、ng() return cityName; Override public boolean equals(Object obj) if (obj instanceof City) City temp = (City) obj; if (this.cityName.equals(temp.cityName) return true; return false; - MoneyLeast-/* * MoneyLeast 查找从花费最少的路径,及乘车路径 * 使用的是普里姆算法 */package com.consel;public class MoneyLeast final static int

6、 maxMoney = 10000; int n; int s;/s用来存储n个节点的标记 int minMoney, u = 0; /t为列车信息图,c为起始城市,数组money是用来存储最少花费的路径,path是用来存储节点的上一节点 public void leastMoney(TrainGraph t, City c, int money, City path) throws Exception n = t.getNumOfVer(); s = new intn; for (int i = 0; i n; i+) moneyi = t.getMoney(c, t.city.get(i)

7、; si = 0; if (moneyi maxMoney) pathi = c; else pathi = null; st.city.indexOf(c) = 1; for (int i = 0; i n; i+) minMoney = maxMoney; for (int j = 0; j n; j+) if (sj = 0 & moneyj minMoney) u = j; minMoney = moneyj; if (minMoney = maxMoney) return; su = 1; City city = t.city.get(u); for (int j = 0; j n;

8、 j+) if (sj = 0 & t.getMoney(city, t.city.get(j) maxMoney & moneyu + t.getMoney(city, t.city.get(j) moneyj) moneyj = moneyu + t.getMoney(city, t.city.get(j); pathj = city; - MoneyTest-package com.consel;import java.util.Iterator;import java.util.Stack;public class MoneyTest MoneyLeast ml = new Money

9、Least(); TrainGraph tg = new TrainGraph(); int money; City path; public Stack st = new Stack(); public MoneyTest() int n = tg.city.size(); money = new intn; path = new Cityn; for (int i = 0; i n; i+) moneyi = tg.maxMoney; pathi = null; public Stack findMoneyLeast(City c1,City c2) throws Exception ml

10、.leastMoney(tg, c1,money, path); Stack s = new Stack(); s.add(c2); while (!c2.equals(c1) City c3 = pathtg.city.indexOf(c2); s.add(c3); TrainContral ct = new TrainContral(); ct.trainRead(); Iterator i = ct.train.iterator(); while(i.hasNext() Train temp = i.next(); if(temp.getStartCity().equals(c3) & temp.getEndCity().equals(c2) st.add(temp); c2 = c3; return s; - Train-/* * Train 序列化,存储列车的信息,包括ID,起始站,终点站,发车时间,到站时间,价格 */package com.consel;import java.util.*;import java.io.Serializable;public class Train implemen

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 资格认证/考试 > 自考

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号