ImageVerifierCode 换一换
格式:DOCX , 页数:35 ,大小:21.53KB ,
资源ID:8206954      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8206954.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(秦皇岛公交信息查询系统单机测试平台.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

秦皇岛公交信息查询系统单机测试平台.docx

1、秦皇岛公交信息查询系统单机测试平台/BusSystem.java /秦皇岛公交信息查询系统单机测试平台/用于以窗口形式输入查询站点,输出乘车方案import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.TitledBorder;public class BusSystem extends JFrame implements ActionListener private JTextField jtfBeginSta=new JTextField(10); private JTe

2、xtField jtfEndSta=new JTextField(10); private JTextArea jtaResult; private JButton jbtQuery=new JButton(查询); public BusSystem() /jtfBeginSta.setHorizontalAlignment(JTextField.RIGHT); /jtfEndSta.setHorizontalAlignment(JTextField.RIGHT); JScrollPane scrollPane=new JScrollPane(jtaResult=new JTextArea()

3、; jtaResult.setEditable(false); JPanel p1=new JPanel(); p1.setLayout(new GridLayout(2,3); p1.add( new Label( 起点车站); p1.add( jtfBeginSta); p1.add( new Label( 终点车站); p1.add( jtfEndSta); JPanel p3=new JPanel(); p3.setLayout(new BorderLayout(2,1); p3.add( new Label(查询结果),BorderLayout.NORTH); p3.add( scr

4、ollPane,BorderLayout.CENTER ); p1.setBorder(new TitledBorder( ); JPanel p2=new JPanel(); p2.setLayout( new FlowLayout(FlowLayout.RIGHT); p2.add( jbtQuery ); getContentPane().add(p1,BorderLayout.NORTH); getContentPane().add(p2,BorderLayout.SOUTH); getContentPane().add(p3,BorderLayout.CENTER); jbtQuer

5、y.addActionListener(this); public static void main(String args) BusSystem frame=new BusSystem(); frame.setTitle(秦皇岛公交信息查询系统); frame.setSize(300,500); frame.setVisible(true); public void actionPerformed(ActionEvent e) if(e.getSource ()=jbtQuery ) String beginSta=jtfBeginSta.getText(); String endSta=j

6、tfEndSta.getText(); String resultQuery; boolean isFinded; Finding_way myFind=new Finding_way(); myFind.createFindWay( beginSta,endSta ); isFinded=myFind. find_bestway (); if(isFinded) resultQuery=myFind.output(); / System.out.println(myFind.output(); else resultQuery=对不起,未找到可行方案!n; jtaResult.setText

7、(resultQuery); /Finding_way.java/该类用来计算乘车方案。import .URL;import java.sql.*;public class Finding_way private Beg_end_sta inputstation;/起始站点 private Path bestpath;/20个乘车方案 private boolean isfinding;/是否找到可行的乘车方案 private int pathTotal; private int errState=0;/1 表示没有直达方案 2表示起点站与终点站为同一站点 /3 表示间接查询中,起点站不存在

8、5该车次无车站 /6 倒一次车的中间站点不存在 public Finding_way() public Finding_way( Beg_end_sta inputstation,Path bestpath, boolean isfinding ) this.inputstation=inputstation; this.bestpath=bestpath; this.isfinding=isfinding; public Finding_way ( Beg_end_sta inputstation ) this.inputstation=inputstation; public void c

9、reateFindWay(Beg_end_sta inputstation) this.inputstation=new Beg_end_sta(); this.inputstation=inputstation; this.bestpath=new Path20; public void createFindWay(Station begining,Station ending ) inputstation=new Beg_end_sta(); inputstation.set_be_sta( begining , ending ); bestpath=new Path20; for ( i

10、nt i=0; i20; i+) bestpathi=new Path(); public void createFindWay(String begining,String ending ) inputstation=new Beg_end_sta(); inputstation.set_be_sta( new Station(begining) , new Station (ending) ); bestpath=new Path20; for ( int i=0; i20; i+) bestpathi=new Path(); public void setinputstation (Be

11、g_end_sta inputstation ) this.inputstation=inputstation; public Beg_end_sta getinputstation( ) return inputstation; public void setbestpath(Path bestpath ) this.bestpath=bestpath; public Path getbestpath() return bestpath; public void setisfinding( boolean isfinding ) this.isfinding=isfinding; /给出不倒

12、车直接到达的方案 public boolean direct_find() int i=0; int resBegSeq,resEndSeq; int resBegSeqShadow,resEndSeqShadow; int distance;/起点站到终点站所经过的车站数 String resBusNo=new String 20; String begining,ending; String queryBusNo,queryBegSeq,queryEndSeq,queryPassSta; String queryPath; /String busNo; begining=inputstat

13、ion.getBegName(); ending=inputstation.getEndName(); if(begining=ending) /System.out.println(起点和终点是同一站点); errState=2; /起点和终点是同一站点 return false; queryBusNo=SELECT bus_no FROM bus_table WHERE station_name= + begining + AND bus_no In ( SELECT bus_no FROM bus_table WHERE station_name= + ending +); try Cl

14、ass.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection con=DriverManager.getConnection(jdbc:odbc:bus); Statement stmt; stmt=con.createStatement(); ResultSet resultBusNo ,resultBegSeq,resultEndSeq,resultPassSta; resultBusNo=stmt.executeQuery( queryBusNo ); /System.out.println(resultBusNo); /找到从起点直达终点的

15、一系列公交车次 /System.out.println(resultBusNo); /* if (resultBusNo)/找到合适的函数来检查是否有有效数据! System.out.println(无可行方案 ); errState=1; return false; */ if( !resultBusNo.next() ) errState=1; /System.out.println(resBusNo0+dd); return false; else resBusNoi=resultBusNo.getString(1); bestpathi.addSegment( resBusNoi );

16、 i+; while( resultBusNo.next() & i20 ) resBusNoi=resultBusNo.getString(1); bestpathi.addSegment( resBusNoi ); /System.out.print(s+resBusNoi+f ); i+; pathTotal=i; resultBusNo.close(); /System.out.println( ); /System.out.println( ); /找到各公交车次中从起点车站到终点车站在整条公交线路中所经过的车站 /System.out.println( i=+i); for(int

17、 j=0;j0) queryPath= ; else queryPath= DESC ; /System.out.println(queryPath); queryPath=SELECT station_name FROM bus_table WHERE bus_no=+resBusNoj+ AND station_sequence BETWEEN +resBegSeq+ AND +resEndSeq+ ORDER BY station_sequence +queryPath; /System.out.println(queryPath); resultPassSta=stmt.execute

18、Query(queryPath); /ResultSetMetaData rsmd=resultPassSta.getMetaData(); /int numCols=rsmd.getColumnCount(); /System.out.print( 乘车路线: +resBusNoj+路车方案 ); String busStation; int q=0; while(resultPassSta.next() busStation=resultPassSta.getString(1); / System.out.print( busStation+ ); bestpathj.setPassSeg

19、ment( busStation,q,0); /System.out.print( ); q+; /resEndSeq=resultEndSeq.getInt(station_sequence); /System.out.println(resEndSeq); resultPassSta.close(); /System.out.println(); /System.out.println(); /System.out.println( ); / System.out.println(Create successfully!); /resultBegSeq.close(); /resultEn

20、dSeq.close(); stmt.close(); con.close(); catch(SQLException ex) System.out.println(n*SQLException Caught *n); while(ex!=null) System.out.println( SQLState: +ex.getSQLState() ); System.out.println( Message: +ex.getMessage() ); System.out.println(Vendor: +ex.getErrorCode(); ex=ex.getNextException(); S

21、ystem.out.println( ); catch(java.lang.Exception ex ) ex.printStackTrace(); return true; /给出倒一次车的,间接到达方案 public boolean indirect_find() String begining=inputstation.getBegName(); String ending=inputstation.getEndName(); String queBegBusNo=SELECT bus_no FROM bus_table WHERE station_name=+begining+; St

22、ring queEndBusNo=SELECT bus_no FROM bus_table WHERE station_name=+ending+; String begBusNo=new String 20; String endBusNo=new String 20; String midBusSta=new String 20; int i=0,j=0; /System.out.println(queBegBusNo); try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection con=DriverManager.getCon

23、nection(jdbc:odbc:bus); Statement stmt; stmt=con.createStatement(); ResultSet resultBegBusNo,resultEndBusNo; /经过起始站点的线路名称 resultBegBusNo=stmt.executeQuery( queBegBusNo ); if( !resultBegBusNo.next() ) /System.out.println(resBusNo0+dd); /间接查询中,起点站不存在,为错误三 errState=3; return false; else begBusNoi=resul

24、tBegBusNo.getString(1); /System.out.print(begBusNoi+ ); i+; while( resultBegBusNo.next() & i20 ) begBusNoi=resultBegBusNo.getString(1); /System.out.print(begBusNoi+ ); i+; resultBegBusNo.close(); /System.out.println(beging and end); resultEndBusNo=stmt.executeQuery( queEndBusNo ); if( !resultEndBusN

25、o.next() ) /间接查询中,终点站不存在,为错误三 errState=3; return false; else endBusNoj=resultEndBusNo.getString(1); / System.out.print(endBusNoj+ ); j+; while( resultEndBusNo.next() & i20 ) endBusNoj=resultEndBusNo.getString(1); /System.out.print(endBusNoj+ ); j+; resultEndBusNo.close(); /System.out.println(bus station); int q=0,l=0,k=0; /ResultSet resultBegBusNo,resultEndBusNo; String passBegSta=new String 40; String passEndSta=new String 40; String quePassBegSta, quePassEndSta; /System.out.println(i+bus station+j); for(int n=0; ni; n+) for(int m=0; mj; m+) /查找起点站可以到

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1