一、项目任务
这次的任务是结对开发,做的是石家庄地铁线路图。
我们一共建了7个表,其中6个是单独一条路线的,一个是显示换成的路线的,我们一致认为,所有路线换成一次就可以到达目的地。
现在,在路线上实现了一些基本功能,并且没有实现页面画,只是在控制台将路线显示出来,等待后期进行优化。
目前在直接到达和部分换乘上都已经实现了基本功能。
二、PSPO总结
项目:石家庄地铁线路图
搭档:靳晨晨
三、实验源代码
1 package com.sub.servlet; 2 3 import java.io.IOException; 4 import java.sql.Connection; 5 import java.sql.DriverManager; 6 import java.sql.ResultSet; 7 import java.sql.Statement; 8 import java.util.ArrayList; 9 import java.util.List; 10 11 import javax.servlet.ServletException; 12 import javax.servlet.annotation.WebServlet; 13 import javax.servlet.http.HttpServlet; 14 import javax.servlet.http.HttpServletRequest; 15 import javax.servlet.http.HttpServletResponse; 16 import com.sub.entity.subway; 17 import com.sub.dao.Dao; 18 /** 19 * Servlet implementation class Servlet 20 */ 21 @WebServlet("/Servlet") 22 public class Servlet extends HttpServlet { 23 private static final long serialVersionUID = 1L; 24 Dao dao=new Dao(); 25 protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 request.setCharacterEncoding("utf-8"); 27 String method = request.getParameter("method"); 28 29 if ("chaxun".equals(method)) { 30 chaxun(request, response); 31 } 32 } 33 private void chaxun(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { 34 String start=request.getParameter("start"); 35 String end=request.getParameter("end"); 36 int a[]=new int[2]; 37 int b[]=new int[2]; 38 int k[]=new int[4]; 39 a=dao.getLineshuzu(start); 40 b=dao.getLineshuzu(end); 41 if((dao.site(start)||dao.site2(start)||dao.site3(start)||dao.site4(start)||dao.site5(start)||dao.site6(start))&&((dao.site(end)||dao.site2(end)||dao.site3(end)||dao.site4(end)||dao.site5(end)||dao.site6(end)))) 42 { 43 if(((dao.getSum(start)>1&&dao.getSum(end)==1)||(dao.getSum(start)==1&&dao.getSum(end)>1)||(dao.getSum(start)>1&&dao.getSum(end)>1))&&((a[0]!=b[0])&&(a[0]!=b[1])&&(a[1]!=b[0])&&(a[1]!=b[1]))) 44 { 45 String route=""; 46 int []temp=new int[4]; 47 int temp1=0; 48 temp[0]=0;temp[1]=1;temp[2]=2;temp[3]=3; 49 k[0]=a[0];k[1]=a[1];k[2]=b[0];k[3]=b[1]; 50 System.out.println(k[0]+","+k[1]+","+k[2]+","+k[3]); 51 String a1=dao.getdouble(k[0], k[2]); 52 String b1=dao.getdouble(k[0], k[3]); 53 String c1=dao.getdouble(k[1], k[2]); 54 String d1=dao.getdouble(k[1], k[3]); 55 System.out.println(a1+","+b1+","+c1+","+d1); 56 if(k[0]!=0&&k[2]!=0) 57 {if(temp[temp1]==0) 58 { 59 System.out.println(""); 60 System.out.println("----------------线路Ⅰ:----------------"); 61 route=route+"-----线路Ⅰ:"; 62 } 63 if(temp[temp1]==1) 64 { 65 System.out.println(""); 66 System.out.println("----------------线路Ⅱ:----------------"); 67 route=route+"-----线路Ⅱ:"; 68 } 69 if(temp[temp1]==2) 70 { 71 System.out.println(""); 72 System.out.println("----------------线路Ⅲ:----------------"); 73 route=route+"-----线路Ⅲ:"; 74 } 75 if(temp[temp1]==3) 76 { 77 System.out.println(""); 78 System.out.println("----------------线路Ⅳ:----------------"); 79 route=route+"-----线路Ⅳ:"; 80 } 81 route=route+dao.getdoublesite(k[0], k[2], start, end); 82 temp1++; 83 }//0-2 84 if(k[0]!=0&&k[3]!=0) 85 {if(temp[temp1]==0) 86 { 87 System.out.println(""); 88 System.out.println("----------------线路Ⅰ:----------------"); 89 route=route+"-----线路Ⅰ:"; 90 } 91 if(temp[temp1]==1) 92 { 93 System.out.println(""); 94 System.out.println("----------------线路Ⅱ:----------------"); 95 route=route+"-----线路Ⅱ:"; 96 } 97 if(temp[temp1]==2) 98 { 99 System.out.println(""); 100 System.out.println("----------------线路Ⅲ:----------------"); 101 route=route+"-----线路Ⅲ:"; 102 } 103 if(temp[temp1]==3) 104 { 105 System.out.println(""); 106 System.out.println("----------------线路Ⅳ:----------------"); 107 route=route+"-----线路Ⅳ:"; 108 } 109 route=route+dao.getdoublesite(k[0], k[3], start, end); 110 temp1++; 111 }//0-3 112 if(k[1]!=0&&k[2]!=0) 113 {if(temp[temp1]==0) 114 { 115 System.out.println(""); 116 System.out.println("----------------线路Ⅰ:----------------"); 117 route=route+"-----线路Ⅰ:"; 118 } 119 if(temp[temp1]==1) 120 { 121 System.out.println(""); 122 System.out.println("----------------线路Ⅱ:----------------"); 123 route=route+"-----线路Ⅱ:"; 124 } 125 if(temp[temp1]==2) 126 { 127 System.out.println(""); 128 System.out.println("----------------线路Ⅲ:----------------"); 129 route=route+"-----线路Ⅲ:"; 130 } 131 if(temp[temp1]==3) 132 { 133 System.out.println(""); 134 System.out.println("----------------线路Ⅳ:----------------"); 135 route=route+"-----线路Ⅳ:"; 136 } 137 route=route+dao.getdoublesite(k[1], k[2], start, end); 138 temp1++; 139 }//1-2 140 if(k[1]!=0&&k[3]!=0) 141 {if(temp[temp1]==0) 142 { 143 System.out.println(""); 144 System.out.println("----------------线路Ⅰ:----------------"); 145 route=route+"-----线路Ⅰ:"; 146 } 147 if(temp[temp1]==1) 148 { 149 System.out.println(""); 150 System.out.println("----------------线路Ⅱ:----------------"); 151 route=route+"-----线路Ⅱ:"; 152 } 153 if(temp[temp1]==2) 154 { 155 System.out.println(""); 156 System.out.println("----------------线路Ⅲ:----------------"); 157 route=route+"-----线路Ⅲ:"; 158 } 159 if(temp[temp1]==3) 160 { 161 System.out.println(""); 162 System.out.println("----------------线路Ⅳ:----------------"); 163 route=route+"-----线路Ⅳ:"; 164 } 165 route=route+dao.getdoublesite(k[1], k[3], start, end); 166 temp1++; 167 }//1-3 168 request.setAttribute("data",route ); 169 request.getRequestDispatcher("Query1.jsp").forward(request, response); 170 } 171 if((dao.getSum(start)>1||dao.getSum(end)>1)&&((a[0]==b[0])||(a[0]==b[1])||(a[1]==b[0])||(a[1]==b[1]))) 172 { 173 String route=""; 174 System.out.println(a[0]+","+a[1]+","+b[0]+","+b[1]); 175 if(a[0]==b[0]) 176 { 177 route=dao.getjkl(a[0], start, end); 178 } 179 if(a[0]==b[1]) 180 { 181 route=dao.getjkl(a[0], start, end); 182 } 183 if(a[1]==b[0]) 184 { 185 route=dao.getjkl(a[1], start, end); 186 } 187 if(a[1]==b[1]) 188 { 189 route=dao.getjkl(a[1], start, end); 190 } 191 request.setAttribute("data",route ); 192 request.getRequestDispatcher("Query1.jsp").forward(request, response); 193 } 194 if(dao.site(start)&&dao.site(end)&&(dao.getLine(start)==1)&&(dao.getLine(end)==1)&&dao.getSum(start)==1&&dao.getSum(end)==1) 195 { 196 int num1=dao.getNum(start); 197 int num2=dao.getNum(end); 198 if(num1<=num2) 199 { 200 String line1=dao.getSiter1(num1, num2); 201 System.out.println("路线为:"+line1); 202 String route="路线为:"+line1; 203 request.setAttribute("data",route ); 204 request.getRequestDispatcher("Query1.jsp").forward(request, response); 205 } 206 if(num1>num2) 207 { 208 String line2=dao.getSitek1(num1, num2); 209 System.out.println("路线为:"+line2); 210 String route="路线为:"+line2; 211 request.setAttribute("data",route ); 212 request.getRequestDispatcher("Query1.jsp").forward(request, response); 213 } 214 }//两站都在一号线 215 if(dao.site2(start)&&dao.site2(end)&&(dao.getLine(start)==2)&&(dao.getLine(end)==2)&&dao.getSum(start)==1&&dao.getSum(end)==1) 216 { 217 int num1=dao.getNum2(start); 218 int num2=dao.getNum2(end); 219 if(num1<=num2) 220 { 221 String line1=dao.getSiter2(num1, num2); 222 System.out.println("路线为:"+line1); 223 String route="路线为:"+line1; 224 request.setAttribute("data",route); 225 request.getRequestDispatcher("Query1.jsp").forward(request, response); 226 } 227 if(num1>num2) 228 { 229 String line2=dao.getSitek2(num1, num2); 230 System.out.println("路线为:"+line2); 231 String route="路线为:"+line2; 232 request.setAttribute("data",route ); 233 request.getRequestDispatcher("Query1.jsp").forward(request, response); 234 } 235 }//两站都在二号线 236 if(dao.site3(start)&&dao.site3(end)&&(dao.getLine(start)==3)&&(dao.getLine(end)==3)&&dao.getSum(start)==1&&dao.getSum(end)==1) 237 { 238 int num1=dao.getNum3(start); 239 int num2=dao.getNum3(end); 240 if(num1<=num2) 241 { 242 String line1=dao.getSiter3(num1, num2); 243 System.out.println("路线为:"+line1); 244 String route="路线为:"+line1; 245 request.setAttribute("data",route ); 246 request.getRequestDispatcher("Query1.jsp").forward(request, response); 247 } 248 if(num1>num2) 249 { 250 String line2=dao.getSitek3(num1, num2); 251 System.out.println("路线为:"+line2); 252 String route="路线为:"+line2; 253 request.setAttribute("data",route ); 254 request.getRequestDispatcher("Query1.jsp").forward(request, response); 255 } 256 }//两站都在三号线 257 if(dao.site4(start)&&dao.site4(end)&&(dao.getLine(start)==4)&&(dao.getLine(end)==4)&&dao.getSum(start)==1&&dao.getSum(end)==1) 258 { 259 int num1=dao.getNum4(start); 260 int num2=dao.getNum4(end); 261 if(num1<=num2) 262 { 263 String line1=dao.getSiter4(num1, num2); 264 System.out.println("路线为:"+line1); 265 String route="路线为:"+line1; 266 request.setAttribute("data",route ); 267 request.getRequestDispatcher("Query1.jsp").forward(request, response); 268 } 269 if(num1>num2) 270 { 271 String line2=dao.getSitek4(num1, num2); 272 System.out.println("路线为:"+line2); 273 String route="路线为:"+line2; 274 request.setAttribute("data",route ); 275 request.getRequestDispatcher("Query1.jsp").forward(request, response); 276 } 277 }//两站都在四号线 278 if(dao.site5(start)&&dao.site5(end)&&(dao.getLine(start)==5)&&(dao.getLine(end)==5)&&dao.getSum(start)==1&&dao.getSum(end)==1) 279 { 280 int num1=dao.getNum5(start); 281 int num2=dao.getNum5(end); 282 if(num1<=num2) 283 { 284 String line1=dao.getSiter5(num1, num2); 285 System.out.println("路线为:"+line1); 286 String route="路线为:"+line1; 287 request.setAttribute("data",route ); 288 request.getRequestDispatcher("Query1.jsp").forward(request, response); 289 } 290 if(num1>num2) 291 { 292 String line2=dao.getSitek5(num1, num2); 293 System.out.println("路线为:"+line2); 294 String route="路线为:"+line2; 295 request.setAttribute("data",route ); 296 request.getRequestDispatcher("Query1.jsp").forward(request, response); 297 } 298 }//两站都在五号线 299 if(dao.site6(start)&&dao.site6(end)&&(dao.getLine(start)==6)&&(dao.getLine(end)==6)&&dao.getSum(start)==1&&dao.getSum(end)==1) 300 { 301 int num1=dao.getNum6(start); 302 int num2=dao.getNum6(end); 303 if(num1<=num2) 304 { 305 String line1=dao.getSiter6(num1, num2); 306 System.out.println("路线为:"+line1); 307 String route="路线为:"+line1; 308 request.setAttribute("data",route ); 309 request.getRequestDispatcher("Query1.jsp").forward(request, response); 310 } 311 if(num1>num2) 312 { 313 String line2=dao.getSitek6(num1, num2); 314 System.out.println("路线为:"+line2); 315 String route="路线为:"+line2; 316 request.setAttribute("data",route ); 317 request.getRequestDispatcher("Query1.jsp").forward(request, response); 318 } 319 }//两站都在六号线 320 if(a[1]==0&&b[1]==0&&a[0]!=b[0]&&dao.getSum(start)==1&&dao.getSum(end)==1)//所有换乘(不包括任意换乘点) 321 { 322 String route=""; 323 int []d=new int[4]; 324 String []c=new String[2]; 325 System.out.println(a[0]+","+b[0]); 326 c=dao.getgline(a, b); 327 d=dao.getviewnum(a, b, c, start, end); 328 route=dao.getview(a, b, d[0], d[2],d[1],d[3]); 329 if(c[1]!="") 330 { 331 String route1=""; 332 System.out.println(""); 333 System.out.print("第二条路线:"); 334 c=dao.getgline(a, b); 335 d=dao.getviewnum1(a, b, c, start, end); 336 route=route+"**********"; 337 route1=dao.getview(a, b, d[0], d[2],d[1],d[3]); 338 route=route+"第二条路线:"+route1; 339 } 340 request.setAttribute("data",route ); 341 request.getRequestDispatcher("Query1.jsp").forward(request, response); 342 } 343 } 344 else 345 { 346 request.setAttribute("data","输入站点有误!" ); 347 request.getRequestDispatcher("Query1.jsp").forward(request, response); 348 } 349 } 350 }
1 Hauncheng.java 2 3 package com.sub.entity; 4 5 public class huancheng { 6 private int first; 7 private int sec; 8 private String site; 9 public int getFirst() { 10 return first; 11 } 12 public void setFirst(int first) { 13 this.first = first; 14 } 15 public int getSec() { 16 return sec; 17 } 18 public void setSec(int sec) { 19 this.sec = sec; 20 } 21 public String getSite() { 22 return site; 23 } 24 public void setSite(String site) { 25 this.site = site; 26 } 27 28 }
1 package com.sub.entity; 2 /** 3 * 4 * @author lenovo 5 * 6 */ 7 public class subway { 8 private int line; 9 private int num; 10 private String site; 11 public int getLine() { 12 return line; 13 } 14 public void setLine(int line) { 15 this.line = line; 16 } 17 public int getNum() { 18 return num; 19 } 20 public void setNum(int num) { 21 this.num = num; 22 } 23 public String getSite() { 24 return site; 25 } 26 public void setSite(String site) { 27 this.site = site; 28 } 29 }
1 package com.sub.DBUtil; 2 3 import java.sql.Connection; 4 import java.sql.DriverManager; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.sql.Statement; 8 9 public class DBUtil { 10 public static String db_url = "jdbc:mysql://localhost:3306/subway"; 11 public static String db_user = "root"; 12 public static String db_pass = "20173673"; 13 14 public static Connection getConn () { 15 Connection conn = null; 16 17 try { 18 Class.forName("com.mysql.jdbc.Driver");//加载驱动 19 conn = DriverManager.getConnection(db_url, db_user, db_pass); 20 } catch (Exception e) { 21 e.printStackTrace(); 22 } 23 24 return conn; 25 } 26 27 /** 28 * 关闭连接 29 * @param state 30 * @param conn 31 */ 32 public static void close (Statement state, Connection conn) { 33 if (state != null) { 34 try { 35 state.close(); 36 } catch (SQLException e) { 37 e.printStackTrace(); 38 } 39 } 40 41 if (conn != null) { 42 try { 43 conn.close(); 44 } catch (SQLException e) { 45 e.printStackTrace(); 46 } 47 } 48 } 49 50 public static void close (ResultSet rs, Statement state, Connection conn) { 51 if (rs != null) { 52 try { 53 rs.close(); 54 } catch (SQLException e) { 55 e.printStackTrace(); 56 } 57 } 58 59 if (state != null) { 60 try { 61 state.close(); 62 } catch (SQLException e) { 63 e.printStackTrace(); 64 } 65 } 66 67 if (conn != null) { 68 try { 69 conn.close(); 70 } catch (SQLException e) { 71 e.printStackTrace(); 72 } 73 } 74 } 75 }
1 package com.sub.dao; 2 import java.sql.Connection; 3 import java.sql.ResultSet; 4 import java.sql.SQLException; 5 import java.sql.Statement; 6 import java.util.ArrayList; 7 import java.util.List; 8 9 import com.sub.DBUtil.*; 10 import com.sub.entity.*; 11 public class Dao { 12 public boolean site(String site) {//在一号线中查看是否存在该站 13 boolean flag = false; 14 String sql = "select site from station where site = '" + site + "'"; 15 Connection conn = DBUtil.getConn(); 16 Statement state = null; 17 ResultSet rs = null; 18 19 try { 20 state = conn.createStatement(); 21 rs = state.executeQuery(sql); 22 while (rs.next()) { 23 flag = true; 24 } 25 } catch (SQLException e) { 26 e.printStackTrace(); 27 } finally { 28 DBUtil.close(rs, state, conn); 29 } 30 return flag; 31 } 32 public boolean site2(String site) {//在二号线中查看是否存在该站 33 boolean flag = false; 34 String sql = "select site from station2 where site = '" + site + "'"; 35 Connection conn = DBUtil.getConn(); 36 Statement state = null; 37 ResultSet rs = null; 38 39 try { 40 state = conn.createStatement(); 41 rs = state.executeQuery(sql); 42 while (rs.next()) { 43 flag = true; 44 } 45 } catch (SQLException e) { 46 e.printStackTrace(); 47 } finally { 48 DBUtil.close(rs, state, conn); 49 } 50 return flag; 51 } 52 public boolean site3(String site) {//在三号线中查看是否存在该站 53 boolean flag = false; 54 String sql = "select site from station3 where site = '" + site + "'"; 55 Connection conn = DBUtil.getConn(); 56 Statement state = null; 57 ResultSet rs = null; 58 59 try { 60 state = conn.createStatement(); 61 rs = state.executeQuery(sql); 62 while (rs.next()) { 63 flag = true; 64 } 65 } catch (SQLException e) { 66 e.printStackTrace(); 67 } finally { 68 DBUtil.close(rs, state, conn); 69 } 70 return flag; 71 } 72 public boolean site4(String site) {//在四号线中查看是否存在该站 73 boolean flag = false; 74 String sql = "select site from station4 where site = '" + site + "'"; 75 Connection conn = DBUtil.getConn(); 76 Statement state = null; 77 ResultSet rs = null; 78 79 try { 80 state = conn.createStatement(); 81 rs = state.executeQuery(sql); 82 while (rs.next()) { 83 flag = true; 84 } 85 } catch (SQLException e) { 86 e.printStackTrace(); 87 } finally { 88 DBUtil.close(rs, state, conn); 89 } 90 return flag; 91 } 92 public boolean site5(String site) {//在五号线中查看是否存在该站 93 boolean flag = false; 94 String sql = "select site from station5 where site = '" + site + "'"; 95 Connection conn = DBUtil.getConn(); 96 Statement state = null; 97 ResultSet rs = null; 98 99 try { 100 state = conn.createStatement(); 101 rs = state.executeQuery(sql); 102 while (rs.next()) { 103 flag = true; 104 } 105 } catch (SQLException e) { 106 e.printStackTrace(); 107 } finally { 108 DBUtil.close(rs, state, conn); 109 } 110 return flag; 111 } 112 public boolean site6(String site) {//在六号线中查看是否存在该站 113 boolean flag = false; 114 String sql = "select site from station6 where site = '" + site + "'"; 115 Connection conn = DBUtil.getConn(); 116 Statement state = null; 117 ResultSet rs = null; 118 119 try { 120 state = conn.createStatement(); 121 rs = state.executeQuery(sql); 122 while (rs.next()) { 123 flag = true; 124 } 125 } catch (SQLException e) { 126 e.printStackTrace(); 127 } finally { 128 DBUtil.close(rs, state, conn); 129 } 130 return flag; 131 } 132 133 public int getNum(String site) {//在一号线中查找编号 134 int num=0; 135 String sql = "select * from station"; 136 Connection conn = DBUtil.getConn(); 137 Statement state = null; 138 ResultSet rs = null; 139 try { 140 state = conn.createStatement(); 141 rs = state.executeQuery(sql); 142 List<subway> list = new ArrayList<subway>(); 143 while (rs.next()) { 144 subway s=new subway(); 145 s.setSite(rs.getString("site")); 146 s.setNum(rs.getInt("num")); 147 if(s.getSite().equals(site)) 148 { 149 num=s.getNum(); 150 } 151 } 152 } catch (Exception e) { 153 e.printStackTrace(); 154 } finally { 155 DBUtil.close(rs, state, conn); 156 } 157 158 return num; 159 } 160 public int getNum2(String site) {//在二号线中查找编号 161 int num=0; 162 String sql = "select * from station2"; 163 Connection conn = DBUtil.getConn(); 164 Statement state = null; 165 ResultSet rs = null; 166 try { 167 state = conn.createStatement(); 168 rs = state.executeQuery(sql); 169 List<subway> list = new ArrayList<subway>(); 170 while (rs.next()) { 171 subway s=new subway(); 172 s.setSite(rs.getString("site")); 173 s.setNum(rs.getInt("num")); 174 if(s.getSite().equals(site)) 175 { 176 num=s.getNum(); 177 } 178 } 179 } catch (Exception e) { 180 e.printStackTrace(); 181 } finally { 182 DBUtil.close(rs, state, conn); 183 } 184 185 return num; 186 } 187 public int getNum3(String site) {//在三号线中查找编号 188 int num=0; 189 String sql = "select * from station3"; 190 Connection conn = DBUtil.getConn(); 191 Statement state = null; 192 ResultSet rs = null; 193 try { 194 state = conn.createStatement(); 195 rs = state.executeQuery(sql); 196 List<subway> list = new ArrayList<subway>(); 197 while (rs.next()) { 198 subway s=new subway(); 199 s.setSite(rs.getString("site")); 200 s.setNum(rs.getInt("num")); 201 if(s.getSite().equals(site)) 202 { 203 num=s.getNum(); 204 } 205 } 206 } catch (Exception e) { 207 e.printStackTrace(); 208 } finally { 209 DBUtil.close(rs, state, conn); 210 } 211 212 return num; 213 } 214 public int getNum4(String site) {//在四号线中查找编号 215 int num=0; 216 String sql = "select * from station4"; 217 Connection conn = DBUtil.getConn(); 218 Statement state = null; 219 ResultSet rs = null; 220 try { 221 state = conn.createStatement(); 222 rs = state.executeQuery(sql); 223 List<subway> list = new ArrayList<subway>(); 224 while (rs.next()) { 225 subway s=new subway(); 226 s.setSite(rs.getString("site")); 227 s.setNum(rs.getInt("num")); 228 if(s.getSite().equals(site)) 229 { 230 num=s.getNum(); 231 } 232 } 233 } catch (Exception e) { 234 e.printStackTrace(); 235 } finally { 236 DBUtil.close(rs, state, conn); 237 } 238 239 return num; 240 } 241 public int getNum5(String site) {//在五号线中查找编号 242 int num=0; 243 String sql = "select * from station5"; 244 Connection conn = DBUtil.getConn(); 245 Statement state = null; 246 ResultSet rs = null; 247 try { 248 state = conn.createStatement(); 249 rs = state.executeQuery(sql); 250 List<subway> list = new ArrayList<subway>(); 251 while (rs.next()) { 252 subway s=new subway(); 253 s.setSite(rs.getString("site")); 254 s.setNum(rs.getInt("num")); 255 if(s.getSite().equals(site)) 256 { 257 num=s.getNum(); 258 } 259 } 260 } catch (Exception e) { 261 e.printStackTrace(); 262 } finally { 263 DBUtil.close(rs, state, conn); 264 } 265 266 return num; 267 } 268 public int getNum6(String site) {//在六号线中查找编号 269 int num=0; 270 String sql = "select * from station6"; 271 Connection conn = DBUtil.getConn(); 272 Statement state = null; 273 ResultSet rs = null; 274 try { 275 state = conn.createStatement(); 276 rs = state.executeQuery(sql); 277 List<subway> list = new ArrayList<subway>(); 278 while (rs.next()) { 279 subway s=new subway(); 280 s.setSite(rs.getString("site")); 281 s.setNum(rs.getInt("num")); 282 if(s.getSite().equals(site)) 283 { 284 num=s.getNum(); 285 } 286 } 287 } catch (Exception e) { 288 e.printStackTrace(); 289 } finally { 290 DBUtil.close(rs, state, conn); 291 } 292 293 return num; 294 } 295 296 public String getSiter1(int num1,int num2) {//一号线求路线 297 String line1=""; 298 String sql = "select * from station"; 299 Connection conn = DBUtil.getConn(); 300 Statement state = null; 301 ResultSet rs = null; 302 try { 303 state = conn.createStatement(); 304 rs = state.executeQuery(sql); 305 List<subway> list = new ArrayList<subway>(); 306 while (rs.next()) { 307 subway s=new subway(); 308 s.setSite(rs.getString("site")); 309 s.setNum(rs.getInt("num")); 310 if(s.getNum()>=num1&&s.getNum()<=num2) 311 { 312 if(s.getNum()!=num2) 313 line1=line1+s.getSite()+"->"; 314 if(s.getNum()==num2) 315 { 316 line1=line1+s.getSite(); 317 } 318 } 319 } 320 } catch (Exception e) { 321 e.printStackTrace(); 322 } finally { 323 DBUtil.close(rs, state, conn); 324 } 325 326 return line1; 327 } 328 public String getSitek1(int num1,int num2) {//一号线求路线 329 String []a=new String[num1-num2+1]; 330 String line2=""; 331 String sql = "select * from station"; 332 Connection conn = DBUtil.getConn(); 333 Statement state = null; 334 ResultSet rs = null; 335 int i=0; 336 try { 337 state = conn.createStatement(); 338 rs = state.executeQuery(sql); 339 List<subway> list = new ArrayList<subway>(); 340 while (rs.next()) { 341 subway s=new subway(); 342 s.setSite(rs.getString("site")); 343 s.setNum(rs.getInt("num")); 344 if(s.getNum()>=num2&&s.getNum()<=num1) 345 { 346 if(s.getNum()==num2) 347 { 348 a[i]=s.getSite(); 349 i++; 350 } 351 if(s.getNum()!=num2) 352 { 353 a[i]=s.getSite()+"->"; 354 i++; 355 } 356 } 357 } 358 } catch (Exception e) { 359 e.printStackTrace(); 360 } finally { 361 DBUtil.close(rs, state, conn); 362 } 363 for(int j=num1-num2;j>=0;j--) 364 { 365 line2=line2+a[j]; 366 } 367 return line2; 368 } 369 public String getSiter2(int num1,int num2) {//二号线求路线 370 String line1=""; 371 String sql = "select * from station2"; 372 Connection conn = DBUtil.getConn(); 373 Statement state = null; 374 ResultSet rs = null; 375 try { 376 state = conn.createStatement(); 377 rs = state.executeQuery(sql); 378 List<subway> list = new ArrayList<subway>(); 379 while (rs.next()) { 380 subway s=new subway(); 381 s.setSite(rs.getString("site")); 382 s.setNum(rs.getInt("num")); 383 if(s.getNum()>=num1&&s.getNum()<=num2) 384 { 385 if(s.getNum()!=num2) 386 line1=line1+s.getSite()+"->"; 387 if(s.getNum()==num2) 388 { 389 line1=line1+s.getSite(); 390 } 391 } 392 } 393 } catch (Exception e) { 394 e.printStackTrace(); 395 } finally { 396 DBUtil.close(rs, state, conn); 397 } 398 399 return line1; 400 } 401 public String getSitek2(int num1,int num2) {//二号线求路线 402 String []a=new String[num1-num2+1]; 403 String line2=""; 404 String sql = "select * from station2"; 405 Connection conn = DBUtil.getConn(); 406 Statement state = null; 407 ResultSet rs = null; 408 int i=0; 409 try { 410 state = conn.createStatement(); 411 rs = state.executeQuery(sql); 412 List<subway> list = new ArrayList<subway>(); 413 while (rs.next()) { 414 subway s=new subway(); 415 s.setSite(rs.getString("site")); 416 s.setNum(rs.getInt("num")); 417 if(s.getNum()>=num2&&s.getNum()<=num1) 418 { 419 if(s.getNum()==num2) 420 { 421 a[i]=s.getSite(); 422 i++; 423 } 424 if(s.getNum()!=num2) 425 { 426 a[i]=s.getSite()+"->"; 427 i++; 428 } 429 } 430 } 431 } catch (Exception e) { 432 e.printStackTrace(); 433 } finally { 434 DBUtil.close(rs, state, conn); 435 } 436 for(int j=num1-num2;j>=0;j--) 437 { 438 line2=line2+a[j]; 439 } 440 return line2; 441 } 442 443 public String getSiter3(int num1,int num2) {//三号线求路线 444 String line1=""; 445 String sql = "select * from station3"; 446 Connection conn = DBUtil.getConn(); 447 Statement state = null; 448 ResultSet rs = null; 449 try { 450 state = conn.createStatement(); 451 rs = state.executeQuery(sql); 452 List<subway> list = new ArrayList<subway>(); 453 while (rs.next()) { 454 subway s=new subway(); 455 s.setSite(rs.getString("site")); 456 s.setNum(rs.getInt("num")); 457 if(s.getNum()>=num1&&s.getNum()<=num2) 458 { 459 if(s.getNum()!=num2) 460 line1=line1+s.getSite()+"->"; 461 if(s.getNum()==num2) 462 { 463 line1=line1+s.getSite(); 464 } 465 } 466 } 467 } catch (Exception e) { 468 e.printStackTrace(); 469 } finally { 470 DBUtil.close(rs, state, conn); 471 } 472 473 return line1; 474 } 475 public String getSitek3(int num1,int num2) {//三号线求路线 476 String []a=new String[num1-num2+1]; 477 String line2=""; 478 String sql = "select * from station3"; 479 Connection conn = DBUtil.getConn(); 480 Statement state = null; 481 ResultSet rs = null; 482 int i=0; 483 try { 484 state = conn.createStatement(); 485 rs = state.executeQuery(sql); 486 List<subway> list = new ArrayList<subway>(); 487 while (rs.next()) { 488 subway s=new subway(); 489 s.setSite(rs.getString("site")); 490 s.setNum(rs.getInt("num")); 491 if(s.getNum()>=num2&&s.getNum()<=num1) 492 { 493 if(s.getNum()==num2) 494 { 495 a[i]=s.getSite(); 496 i++; 497 } 498 if(s.getNum()!=num2) 499 { 500 a[i]=s.getSite()+"->"; 501 i++; 502 } 503 } 504 } 505 } catch (Exception e) { 506 e.printStackTrace(); 507 } finally { 508 DBUtil.close(rs, state, conn); 509 } 510 for(int j=num1-num2;j>=0;j--) 511 { 512 line2=line2+a[j]; 513 } 514 return line2; 515 } 516 517 public String getSiter4(int num1,int num2) {//四号线求路线 518 String line1=""; 519 String sql = "select * from station4"; 520 Connection conn = DBUtil.getConn(); 521 Statement state = null; 522 ResultSet rs = null; 523 try { 524 state = conn.createStatement(); 525 rs = state.executeQuery(sql); 526 List<subway> list = new ArrayList<subway>(); 527 while (rs.next()) { 528 subway s=new subway(); 529 s.setSite(rs.getString("site")); 530 s.setNum(rs.getInt("num")); 531 if(s.getNum()>=num1&&s.getNum()<=num2) 532 { 533 if(s.getNum()!=num2) 534 line1=line1+s.getSite()+"->"; 535 if(s.getNum()==num2) 536 { 537 line1=line1+s.getSite(); 538 } 539 } 540 } 541 } catch (Exception e) { 542 e.printStackTrace(); 543 } finally { 544 DBUtil.close(rs, state, conn); 545 } 546 547 return line1; 548 } 549 public String getSitek4(int num1,int num2) {//四号线求路线 550 String []a=new String[num1-num2+1]; 551 String line2=""; 552 String sql = "select * from station4"; 553 Connection conn = DBUtil.getConn(); 554 Statement state = null; 555 ResultSet rs = null; 556 int i=0; 557 try { 558 state = conn.createStatement(); 559 rs = state.executeQuery(sql); 560 List<subway> list = new ArrayList<subway>(); 561 while (rs.next()) { 562 subway s=new subway(); 563 s.setSite(rs.getString("site")); 564 s.setNum(rs.getInt("num")); 565 if(s.getNum()>=num2&&s.getNum()<=num1) 566 { 567 if(s.getNum()==num2) 568 { 569 a[i]=s.getSite(); 570 i++; 571 } 572 if(s.getNum()!=num2) 573 { 574 a[i]=s.getSite()+"->"; 575 i++; 576 } 577 } 578 } 579 } catch (Exception e) { 580 e.printStackTrace(); 581 } finally { 582 DBUtil.close(rs, state, conn); 583 } 584 for(int j=num1-num2;j>=0;j--) 585 { 586 line2=line2+a[j]; 587 } 588 return line2; 589 } 590 591 public String getSiter5(int num1,int num2) {//五号线求路线 592 String line1=""; 593 String sql = "select * from station5"; 594 Connection conn = DBUtil.getConn(); 595 Statement state = null; 596 ResultSet rs = null; 597 try { 598 state = conn.createStatement(); 599 rs = state.executeQuery(sql); 600 List<subway> list = new ArrayList<subway>(); 601 while (rs.next()) { 602 subway s=new subway(); 603 s.setSite(rs.getString("site")); 604 s.setNum(rs.getInt("num")); 605 if(s.getNum()>=num1&&s.getNum()<=num2) 606 { 607 if(s.getNum()!=num2) 608 line1=line1+s.getSite()+"->"; 609 if(s.getNum()==num2) 610 { 611 line1=line1+s.getSite(); 612 } 613 } 614 } 615 } catch (Exception e) { 616 e.printStackTrace(); 617 } finally { 618 DBUtil.close(rs, state, conn); 619 } 620 621 return line1; 622 } 623 public String getSitek5(int num1,int num2) {//五号线求路线 624 String []a=new String[num1-num2+1]; 625 String line2=""; 626 String sql = "select * from station5"; 627 Connection conn = DBUtil.getConn(); 628 Statement state = null; 629 ResultSet rs = null; 630 int i=0; 631 try { 632 state = conn.createStatement(); 633 rs = state.executeQuery(sql); 634 List<subway> list = new ArrayList<subway>(); 635 while (rs.next()) { 636 subway s=new subway(); 637 s.setSite(rs.getString("site")); 638 s.setNum(rs.getInt("num")); 639 if(s.getNum()>=num2&&s.getNum()<=num1) 640 { 641 if(s.getNum()==num2) 642 { 643 a[i]=s.getSite(); 644 i++; 645 } 646 if(s.getNum()!=num2) 647 { 648 a[i]=s.getSite()+"->"; 649 i++; 650 } 651 } 652 } 653 } catch (Exception e) { 654 e.printStackTrace(); 655 } finally { 656 DBUtil.close(rs, state, conn); 657 } 658 for(int j=num1-num2;j>=0;j--) 659 { 660 line2=line2+a[j]; 661 } 662 return line2; 663 } 664 665 public String getSiter6(int num1,int num2) {//六号线求路线 666 String line1=""; 667 String sql = "select * from station6"; 668 Connection conn = DBUtil.getConn(); 669 Statement state = null; 670 ResultSet rs = null; 671 try { 672 state = conn.createStatement(); 673 rs = state.executeQuery(sql); 674 List<subway> list = new ArrayList<subway>(); 675 while (rs.next()) { 676 subway s=new subway(); 677 s.setSite(rs.getString("site")); 678 s.setNum(rs.getInt("num")); 679 if(s.getNum()>=num1&&s.getNum()<=num2) 680 { 681 if(s.getNum()!=num2) 682 line1=line1+s.getSite()+"->"; 683 if(s.getNum()==num2) 684 { 685 line1=line1+s.getSite(); 686 } 687 } 688 } 689 } catch (Exception e) { 690 e.printStackTrace(); 691 } finally { 692 DBUtil.close(rs, state, conn); 693 } 694 695 return line1; 696 } 697 public String getSitek6(int num1,int num2) {//六号线求路线 698 String []a=new String[num1-num2+1]; 699 String line2=""; 700 String sql = "select * from station6"; 701 Connection conn = DBUtil.getConn(); 702 Statement state = null; 703 ResultSet rs = null; 704 int i=0; 705 try { 706 state = conn.createStatement(); 707 rs = state.executeQuery(sql); 708 List<subway> list = new ArrayList<subway>(); 709 while (rs.next()) { 710 subway s=new subway(); 711 s.setSite(rs.getString("site")); 712 s.setNum(rs.getInt("num")); 713 if(s.getNum()>=num2&&s.getNum()<=num1) 714 { 715 if(s.getNum()==num2) 716 { 717 a[i]=s.getSite(); 718 i++; 719 } 720 if(s.getNum()!=num2) 721 { 722 a[i]=s.getSite()+"->"; 723 i++; 724 } 725 } 726 } 727 } catch (Exception e) { 728 e.printStackTrace(); 729 } finally { 730 DBUtil.close(rs, state, conn); 731 } 732 for(int j=num1-num2;j>=0;j--) 733 { 734 line2=line2+a[j]; 735 } 736 return line2; 737 } 738 739 740 public int getLine(String site) { 741 int sum=0; 742 int line_k=0; 743 String sql = "select * from station"; 744 Connection conn = DBUtil.getConn(); 745 Statement state = null; 746 ResultSet rs = null; 747 try { 748 state = conn.createStatement(); 749 rs = state.executeQuery(sql); 750 List<subway> list = new ArrayList<subway>(); 751 while (rs.next()) { 752 subway s=new subway(); 753 s.setSite(rs.getString("site")); 754 s.setNum(rs.getInt("num")); 755 s.setLine(rs.getInt("line")); 756 if(s.getSite().equals(site)) 757 { 758 line_k=s.getLine(); 759 sum++; 760 } 761 } 762 } catch (Exception e) { 763 e.printStackTrace(); 764 } finally { 765 DBUtil.close(rs, state, conn); 766 }//在一号线中遍历 767 768 String sql1 = "select * from station2"; 769 Connection conn1 = DBUtil.getConn(); 770 Statement state1 = null; 771 ResultSet rs1 = null; 772 try { 773 state1 = conn1.createStatement(); 774 rs1 = state1.executeQuery(sql1); 775 List<subway> list = new ArrayList<subway>(); 776 while (rs1.next()) { 777 subway s=new subway(); 778 s.setSite(rs1.getString("site")); 779 s.setNum(rs1.getInt("num")); 780 s.setLine(rs1.getInt("line")); 781 if(s.getSite().equals(site)) 782 { 783 line_k=s.getLine(); 784 sum++; 785 } 786 } 787 } catch (Exception e) { 788 e.printStackTrace(); 789 } finally { 790 DBUtil.close(rs1, state1, conn1); 791 }//在二号线中遍历 792 793 String sql2 = "select * from station3"; 794 Connection conn2 = DBUtil.getConn(); 795 Statement state2 = null; 796 ResultSet rs2 = null; 797 try { 798 state2 = conn2.createStatement(); 799 rs2 = state2.executeQuery(sql2); 800 List<subway> list = new ArrayList<subway>(); 801 while (rs2.next()) { 802 subway s=new subway(); 803 s.setSite(rs2.getString("site")); 804 s.setNum(rs2.getInt("num")); 805 s.setLine(rs2.getInt("line")); 806 if(s.getSite().equals(site)) 807 { 808 line_k=s.getLine(); 809 sum++; 810 } 811 } 812 } catch (Exception e) { 813 e.printStackTrace(); 814 } finally { 815 DBUtil.close(rs2, state2, conn2); 816 }//在三号线中遍历 817 818 String sql3 = "select * from station4"; 819 Connection conn3 = DBUtil.getConn(); 820 Statement state3 = null; 821 ResultSet rs3 = null; 822 try { 823 state3 = conn3.createStatement(); 824 rs3 = state3.executeQuery(sql3); 825 List<subway> list = new ArrayList<subway>(); 826 while (rs3.next()) { 827 subway s=new subway(); 828 s.setSite(rs3.getString("site")); 829 s.setNum(rs3.getInt("num")); 830 s.setLine(rs3.getInt("line")); 831 if(s.getSite().equals(site)) 832 { 833 line_k=s.getLine(); 834 sum++; 835 } 836 } 837 } catch (Exception e) { 838 e.printStackTrace(); 839 } finally { 840 DBUtil.close(rs3, state3, conn3); 841 }//在四号线中遍历 842 843 String sql4 = "select * from station5"; 844 Connection conn4 = DBUtil.getConn(); 845 Statement state4 = null; 846 ResultSet rs4 = null; 847 try { 848 state4 = conn4.createStatement(); 849 rs4 = state4.executeQuery(sql4); 850 List<subway> list = new ArrayList<subway>(); 851 while (rs4.next()) { 852 subway s=new subway(); 853 s.setSite(rs4.getString("site")); 854 s.setNum(rs4.getInt("num")); 855 s.setLine(rs4.getInt("line")); 856 if(s.getSite().equals(site)) 857 { 858 line_k=s.getLine(); 859 sum++; 860 } 861 } 862 } catch (Exception e) { 863 e.printStackTrace(); 864 } finally { 865 DBUtil.close(rs4, state4, conn4); 866 }//在五号线中遍历 867 868 String sql5 = "select * from station6"; 869 Connection conn5 = DBUtil.getConn(); 870 Statement state5 = null; 871 ResultSet rs5 = null; 872 try { 873 state5 = conn5.createStatement(); 874 rs5 = state5.executeQuery(sql5); 875 List<subway> list = new ArrayList<subway>(); 876 while (rs5.next()) { 877 subway s=new subway(); 878 s.setSite(rs5.getString("site")); 879 s.setNum(rs5.getInt("num")); 880 s.setLine(rs5.getInt("line")); 881 if(s.getSite().equals(site)) 882 { 883 line_k=s.getLine(); 884 sum++; 885 } 886 } 887 } catch (Exception e) { 888 e.printStackTrace(); 889 } finally { 890 DBUtil.close(rs5, state5, conn5); 891 }//在六号线中遍历 892 893 return line_k; 894 } 895 public int[] getLineshuzu(String site) {//获取路线 896 int []a=new int[2]; 897 a[0]=0;a[1]=0; 898 int temp=0; 899 String sql = "select * from station"; 900 Connection conn = DBUtil.getConn(); 901 Statement state = null; 902 ResultSet rs = null; 903 try { 904 state = conn.createStatement(); 905 rs = state.executeQuery(sql); 906 List<subway> list = new ArrayList<subway>(); 907 while (rs.next()) { 908 subway s=new subway(); 909 s.setSite(rs.getString("site")); 910 s.setNum(rs.getInt("num")); 911 s.setLine(rs.getInt("line")); 912 if(s.getSite().equals(site)) 913 { 914 a[temp]=s.getLine(); 915 temp++; 916 } 917 } 918 } catch (Exception e) { 919 e.printStackTrace(); 920 } finally { 921 DBUtil.close(rs, state, conn); 922 }//在一号线中遍历 923 924 String sql1 = "select * from station2"; 925 Connection conn1 = DBUtil.getConn(); 926 Statement state1 = null; 927 ResultSet rs1 = null; 928 try { 929 state1 = conn1.createStatement(); 930 rs1 = state1.executeQuery(sql1); 931 List<subway> list = new ArrayList<subway>(); 932 while (rs1.next()) { 933 subway s=new subway(); 934 s.setSite(rs1.getString("site")); 935 s.setNum(rs1.getInt("num")); 936 s.setLine(rs1.getInt("line")); 937 if(s.getSite().equals(site)) 938 { 939 a[temp]=s.getLine(); 940 temp++; 941 } 942 } 943 } catch (Exception e) { 944 e.printStackTrace(); 945 } finally { 946 DBUtil.close(rs1, state1, conn1); 947 }//在二号线中遍历 948 949 String sql2 = "select * from station3"; 950 Connection conn2 = DBUtil.getConn(); 951 Statement state2 = null; 952 ResultSet rs2 = null; 953 try { 954 state2 = conn2.createStatement(); 955 rs2 = state2.executeQuery(sql2); 956 List<subway> list = new ArrayList<subway>(); 957 while (rs2.next()) { 958 subway s=new subway(); 959 s.setSite(rs2.getString("site")); 960 s.setNum(rs2.getInt("num")); 961 s.setLine(rs2.getInt("line")); 962 if(s.getSite().equals(site)) 963 { 964 a[temp]=s.getLine(); 965 temp++; 966 } 967 } 968 } catch (Exception e) { 969 e.printStackTrace(); 970 } finally { 971 DBUtil.close(rs2, state2, conn2); 972 }//在三号线中遍历 973 974 String sql3 = "select * from station4"; 975 Connection conn3 = DBUtil.getConn(); 976 Statement state3 = null; 977 ResultSet rs3 = null; 978 try { 979 state3 = conn3.createStatement(); 980 rs3 = state3.executeQuery(sql3); 981 List<subway> list = new ArrayList<subway>(); 982 while (rs3.next()) { 983 subway s=new subway(); 984 s.setSite(rs3.getString("site")); 985 s.setNum(rs3.getInt("num")); 986 s.setLine(rs3.getInt("line")); 987 if(s.getSite().equals(site)) 988 { 989 a[temp]=s.getLine(); 990 temp++; 991 } 992 } 993 } catch (Exception e) { 994 e.printStackTrace(); 995 } finally { 996 DBUtil.close(rs3, state3, conn3); 997 }//在四号线中遍历 998 999 String sql4 = "select * from station5"; 1000 Connection conn4 = DBUtil.getConn(); 1001 Statement state4 = null; 1002 ResultSet rs4 = null; 1003 try { 1004 state4 = conn4.createStatement(); 1005 rs4 = state4.executeQuery(sql4); 1006 List<subway> list = new ArrayList<subway>(); 1007 while (rs4.next()) { 1008 subway s=new subway(); 1009 s.setSite(rs4.getString("site")); 1010 s.setNum(rs4.getInt("num")); 1011 s.setLine(rs4.getInt("line")); 1012 if(s.getSite().equals(site)) 1013 { 1014 a[temp]=s.getLine(); 1015 temp++; 1016 } 1017 } 1018 } catch (Exception e) { 1019 e.printStackTrace(); 1020 } finally { 1021 DBUtil.close(rs4, state4, conn4); 1022 }//在五号线中遍历 1023 1024 String sql5 = "select * from station6"; 1025 Connection conn5 = DBUtil.getConn(); 1026 Statement state5 = null; 1027 ResultSet rs5 = null; 1028 try { 1029 state5 = conn5.createStatement(); 1030 rs5 = state5.executeQuery(sql5); 1031 List<subway> list = new ArrayList<subway>(); 1032 while (rs5.next()) { 1033 subway s=new subway(); 1034 s.setSite(rs5.getString("site")); 1035 s.setNum(rs5.getInt("num")); 1036 s.setLine(rs5.getInt("line")); 1037 if(s.getSite().equals(site)) 1038 { 1039 a[temp]=s.getLine(); 1040 temp++; 1041 } 1042 } 1043 } catch (Exception e) { 1044 e.printStackTrace(); 1045 } finally { 1046 DBUtil.close(rs5, state5, conn5); 1047 }//在六号线中遍历 1048 1049 return a; 1050 } 1051 public int getSum(String site) {//获取换乘点所在路线数 1052 int sum=0; 1053 int line_k=0; 1054 String sql = "select * from station"; 1055 Connection conn = DBUtil.getConn(); 1056 Statement state = null; 1057 ResultSet rs = null; 1058 try { 1059 state = conn.createStatement(); 1060 rs = state.executeQuery(sql); 1061 List<subway> list = new ArrayList<subway>(); 1062 while (rs.next()) { 1063 subway s=new subway(); 1064 s.setSite(rs.getString("site")); 1065 s.setNum(rs.getInt("num")); 1066 s.setLine(rs.getInt("line")); 1067 if(s.getSite().equals(site)) 1068 { 1069 line_k=s.getLine(); 1070 sum++; 1071 } 1072 } 1073 } catch (Exception e) { 1074 e.printStackTrace(); 1075 } finally { 1076 DBUtil.close(rs, state, conn); 1077 }//在一号线中遍历 1078 1079 String sql1 = "select * from station2"; 1080 Connection conn1 = DBUtil.getConn(); 1081 Statement state1 = null; 1082 ResultSet rs1 = null; 1083 try { 1084 state1 = conn1.createStatement(); 1085 rs1 = state1.executeQuery(sql1); 1086 List<subway> list = new ArrayList<subway>(); 1087 while (rs1.next()) { 1088 subway s=new subway(); 1089 s.setSite(rs1.getString("site")); 1090 s.setNum(rs1.getInt("num")); 1091 s.setLine(rs1.getInt("line")); 1092 if(s.getSite().equals(site)) 1093 { 1094 line_k=s.getLine(); 1095 sum++; 1096 } 1097 } 1098 } catch (Exception e) { 1099 e.printStackTrace(); 1100 } finally { 1101 DBUtil.close(rs1, state1, conn1); 1102 }//在二号线中遍历 1103 1104 String sql2 = "select * from station3"; 1105 Connection conn2 = DBUtil.getConn(); 1106 Statement state2 = null; 1107 ResultSet rs2 = null; 1108 try { 1109 state2 = conn2.createStatement(); 1110 rs2 = state2.executeQuery(sql2); 1111 List<subway> list = new ArrayList<subway>(); 1112 while (rs2.next()) { 1113 subway s=new subway(); 1114 s.setSite(rs2.getString("site")); 1115 s.setNum(rs2.getInt("num")); 1116 s.setLine(rs2.getInt("line")); 1117 if(s.getSite().equals(site)) 1118 { 1119 line_k=s.getLine(); 1120 sum++; 1121 } 1122 } 1123 } catch (Exception e) { 1124 e.printStackTrace(); 1125 } finally { 1126 DBUtil.close(rs2, state2, conn2); 1127 }//在三号线中遍历 1128 1129 String sql3 = "select * from station4"; 1130 Connection conn3 = DBUtil.getConn(); 1131 Statement state3 = null; 1132 ResultSet rs3 = null; 1133 try { 1134 state3 = conn3.createStatement(); 1135 rs3 = state3.executeQuery(sql3); 1136 List<subway> list = new ArrayList<subway>(); 1137 while (rs3.next()) { 1138 subway s=new subway(); 1139 s.setSite(rs3.getString("site")); 1140 s.setNum(rs3.getInt("num")); 1141 s.setLine(rs3.getInt("line")); 1142 if(s.getSite().equals(site)) 1143 { 1144 line_k=s.getLine(); 1145 sum++; 1146 } 1147 } 1148 } catch (Exception e) { 1149 e.printStackTrace(); 1150 } finally { 1151 DBUtil.close(rs3, state3, conn3); 1152 }//在四号线中遍历 1153 1154 String sql4 = "select * from station5"; 1155 Connection conn4 = DBUtil.getConn(); 1156 Statement state4 = null; 1157 ResultSet rs4 = null; 1158 try { 1159 state4 = conn4.createStatement(); 1160 rs4 = state4.executeQuery(sql4); 1161 List<subway> list = new ArrayList<subway>(); 1162 while (rs4.next()) { 1163 subway s=new subway(); 1164 s.setSite(rs4.getString("site")); 1165 s.setNum(rs4.getInt("num")); 1166 s.setLine(rs4.getInt("line")); 1167 if(s.getSite().equals(site)) 1168 { 1169 line_k=s.getLine(); 1170 sum++; 1171 } 1172 } 1173 } catch (Exception e) { 1174 e.printStackTrace(); 1175 } finally { 1176 DBUtil.close(rs4, state4, conn4); 1177 }//在五号线中遍历 1178 1179 String sql5 = "select * from station6"; 1180 Connection conn5 = DBUtil.getConn(); 1181 Statement state5 = null; 1182 ResultSet rs5 = null; 1183 try { 1184 state5 = conn5.createStatement(); 1185 rs5 = state5.executeQuery(sql5); 1186 List<subway> list = new ArrayList<subway>(); 1187 while (rs5.next()) { 1188 subway s=new subway(); 1189 s.setSite(rs5.getString("site")); 1190 s.setNum(rs5.getInt("num")); 1191 s.setLine(rs5.getInt("line")); 1192 if(s.getSite().equals(site)) 1193 { 1194 line_k=s.getLine(); 1195 sum++; 1196 } 1197 } 1198 } catch (Exception e) { 1199 e.printStackTrace(); 1200 } finally { 1201 DBUtil.close(rs5, state5, conn5); 1202 }//在六号线中遍历 1203 1204 return sum; 1205 } 1206 1207 public String[] getgline(int a[],int b[]) {//在换乘线中查找换乘点 1208 String []site=new String[2]; 1209 site[0]=""; 1210 site[1]=""; 1211 int temp=0; 1212 String sql = "select * from huancheng"; 1213 Connection conn = DBUtil.getConn(); 1214 Statement state = null; 1215 ResultSet rs = null; 1216 try { 1217 state = conn.createStatement(); 1218 rs = state.executeQuery(sql); 1219 List<subway> list = new ArrayList<subway>(); 1220 while (rs.next()) { 1221 huancheng s=new huancheng(); 1222 s.setSite(rs.getString("gsite")); 1223 s.setFirst(rs.getInt("first")); 1224 s.setSec(rs.getInt("sec")); 1225 if(a[0]==s.getFirst()&&b[0]==s.getSec()) 1226 { 1227 site[temp]=s.getSite(); 1228 temp++; 1229 } 1230 } 1231 } catch (Exception e) { 1232 e.printStackTrace(); 1233 } finally { 1234 DBUtil.close(rs, state, conn); 1235 } 1236 1237 return site; 1238 } 1239 public String getview(int a[],int b[],int num1,int num2,int num3,int num4) {//123456 1240 String route=""; 1241 if(a[0]==1&&b[0]==2) 1242 { 1243 if(num1<=num2) 1244 { 1245 String line1=getSiter1(num1, num2); 1246 System.out.print("路线为:"+line1+"->"); 1247 route="路线为:"+line1+"->"; 1248 } 1249 if(num1>num2) 1250 { 1251 String line2=getSitek1(num1, num2); 1252 System.out.print("路线为:"+line2+"->"); 1253 route="路线为:"+line2+"->"; 1254 } 1255 if(num3>num4) 1256 { 1257 String line1=getSiter2(num4, num3); 1258 System.out.print("(换乘)"+line1); 1259 route=route+"(换乘)"+line1; 1260 } 1261 if(num3<=num4) 1262 { 1263 String line2=getSitek2(num4, num3); 1264 System.out.print("(换乘)"+line2); 1265 route=route+"(换乘)"+line2; 1266 } 1267 } 1268 if(a[0]==2&&b[0]==1) 1269 { 1270 if(num1<=num2) 1271 { 1272 String line1=getSiter2(num1, num2); 1273 System.out.print("路线为:"+line1+"->"); 1274 route="路线为:"+line1+"->"; 1275 } 1276 if(num1>num2) 1277 { 1278 String line2=getSitek2(num1, num2); 1279 System.out.print("路线为:"+line2+"->"); 1280 route="路线为:"+line2+"->"; 1281 } 1282 if(num3>num4) 1283 { 1284 String line1=getSiter1(num4, num3); 1285 System.out.print("(换乘)"+line1); 1286 route=route+"(换乘)"+line1; 1287 } 1288 if(num3<=num4) 1289 { 1290 String line2=getSitek1(num4, num3); 1291 System.out.print("(换乘)"+line2); 1292 route=route+"(换乘)"+line2; 1293 } 1294 }//1-2 1295 if(a[0]==1&&b[0]==3) 1296 { 1297 if(num1<=num2) 1298 { 1299 String line1=getSiter1(num1, num2); 1300 System.out.print("路线为:"+line1+"->"); 1301 route="路线为:"+line1+"->"; 1302 } 1303 if(num1>num2) 1304 { 1305 String line2=getSitek1(num1, num2); 1306 System.out.print("路线为:"+line2+"->"); 1307 route="路线为:"+line2+"->"; 1308 } 1309 if(num3>num4) 1310 { 1311 String line1=getSiter3(num4, num3); 1312 System.out.print("(换乘)"+line1); 1313 route=route+"(换乘)"+line1; 1314 } 1315 if(num3<=num4) 1316 { 1317 String line2=getSitek3(num4, num3); 1318 System.out.print("(换乘)"+line2); 1319 route=route+"(换乘)"+line2; 1320 } 1321 } 1322 if(a[0]==3&&b[0]==1) 1323 { 1324 if(num1<=num2) 1325 { 1326 String line1=getSiter3(num1, num2); 1327 System.out.print("路线为:"+line1+"->"); 1328 route="路线为:"+line1+"->"; 1329 } 1330 if(num1>num2) 1331 { 1332 String line2=getSitek3(num1, num2); 1333 System.out.print("路线为:"+line2+"->"); 1334 route="路线为:"+line2+"->"; 1335 } 1336 if(num3>num4) 1337 { 1338 String line1=getSiter1(num4, num3); 1339 System.out.print("(换乘)"+line1); 1340 route=route+"(换乘)"+line1; 1341 } 1342 if(num3<=num4) 1343 { 1344 String line2=getSitek1(num4, num3); 1345 System.out.print("(换乘)"+line2); 1346 route=route+"(换乘)"+line2; 1347 } 1348 }//1-3 1349 if(a[0]==1&&b[0]==4) 1350 { 1351 if(num1<=num2) 1352 { 1353 String line1=getSiter1(num1, num2); 1354 System.out.print("路线为:"+line1+"->"); 1355 route="路线为:"+line1+"->"; 1356 } 1357 if(num1>num2) 1358 { 1359 String line2=getSitek1(num1, num2); 1360 System.out.print("路线为:"+line2+"->"); 1361 route="路线为:"+line2+"->"; 1362 } 1363 if(num3>num4) 1364 { 1365 String line1=getSiter4(num4, num3); 1366 System.out.print("(换乘)"+line1); 1367 route=route+"(换乘)"+line1; 1368 } 1369 if(num3<=num4) 1370 { 1371 String line2=getSitek4(num4, num3); 1372 System.out.print("(换乘)"+line2); 1373 route=route+"(换乘)"+line2; 1374 } 1375 } 1376 if(a[0]==4&&b[0]==1) 1377 { 1378 if(num1<=num2) 1379 { 1380 String line1=getSiter4(num1, num2); 1381 System.out.print("路线为:"+line1+"->"); 1382 route="路线为:"+line1+"->"; 1383 } 1384 if(num1>num2) 1385 { 1386 String line2=getSitek4(num1, num2); 1387 System.out.print("路线为:"+line2+"->"); 1388 route="路线为:"+line2+"->"; 1389 } 1390 if(num3>num4) 1391 { 1392 String line1=getSiter1(num4, num3); 1393 System.out.print("(换乘)"+line1); 1394 route=route+"(换乘)"+line1; 1395 } 1396 if(num3<=num4) 1397 { 1398 String line2=getSitek1(num4, num3); 1399 System.out.print("(换乘)"+line2); 1400 route=route+"(换乘)"+line2; 1401 } 1402 }//1-4 1403 if(a[0]==1&&b[0]==5) 1404 { 1405 if(num1<=num2) 1406 { 1407 String line1=getSiter1(num1, num2); 1408 System.out.print("路线为:"+line1+"->"); 1409 route="路线为:"+line1+"->"; 1410 } 1411 if(num1>num2) 1412 { 1413 String line2=getSitek1(num1, num2); 1414 System.out.print("路线为:"+line2+"->"); 1415 route="路线为:"+line2+"->"; 1416 } 1417 if(num3>num4) 1418 { 1419 String line1=getSiter5(num4, num3); 1420 System.out.print("(换乘)"+line1); 1421 route=route+"(换乘)"+line1; 1422 } 1423 if(num3<=num4) 1424 { 1425 String line2=getSitek5(num4, num3); 1426 System.out.print("(换乘)"+line2); 1427 route=route+"(换乘)"+line2; 1428 } 1429 } 1430 if(a[0]==5&&b[0]==1) 1431 { 1432 if(num1<=num2) 1433 { 1434 String line1=getSiter5(num1, num2); 1435 System.out.print("路线为:"+line1+"->"); 1436 route="路线为:"+line1+"->"; 1437 } 1438 if(num1>num2) 1439 { 1440 String line2=getSitek5(num1, num2); 1441 System.out.print("路线为:"+line2+"->"); 1442 route="路线为:"+line2+"->"; 1443 } 1444 if(num3>num4) 1445 { 1446 String line1=getSiter1(num4, num3); 1447 System.out.print("(换乘)"+line1); 1448 route=route+"(换乘)"+line1; 1449 } 1450 if(num3<=num4) 1451 { 1452 String line2=getSitek1(num4, num3); 1453 System.out.print("(换乘)"+line2); 1454 route=route+"(换乘)"+line2; 1455 } 1456 }//1-5 1457 if(a[0]==1&&b[0]==6) 1458 { 1459 if(num1<=num2) 1460 { 1461 String line1=getSiter1(num1, num2); 1462 System.out.print("路线为:"+line1+"->"); 1463 route="路线为:"+line1+"->"; 1464 } 1465 if(num1>num2) 1466 { 1467 String line2=getSitek1(num1, num2); 1468 System.out.print("路线为:"+line2+"->"); 1469 route="路线为:"+line2+"->"; 1470 } 1471 if(num3>num4) 1472 { 1473 String line1=getSiter6(num4, num3); 1474 System.out.print("(换乘)"+line1); 1475 route=route+"(换乘)"+line1; 1476 } 1477 if(num3<=num4) 1478 { 1479 String line2=getSitek6(num4, num3); 1480 System.out.print("(换乘)"+line2); 1481 route=route+"(换乘)"+line2; 1482 } 1483 } 1484 if(a[0]==6&&b[0]==1) 1485 { 1486 if(num1<=num2) 1487 { 1488 String line1=getSiter6(num1, num2); 1489 System.out.print("路线为:"+line1+"->"); 1490 route="路线为:"+line1+"->"; 1491 } 1492 if(num1>num2) 1493 { 1494 String line2=getSitek6(num1, num2); 1495 System.out.print("路线为:"+line2+"->"); 1496 route="路线为:"+line2+"->"; 1497 } 1498 if(num3>num4) 1499 { 1500 String line1=getSiter1(num4, num3); 1501 System.out.print("(换乘)"+line1); 1502 route=route+"(换乘)"+line1; 1503 } 1504 if(num3<=num4) 1505 { 1506 String line2=getSitek1(num4, num3); 1507 System.out.print("(换乘)"+line2); 1508 route=route+"(换乘)"+line2; 1509 } 1510 }//1-6 1511 if(a[0]==2&&b[0]==3) 1512 { 1513 if(num1<=num2) 1514 { 1515 String line1=getSiter2(num1, num2); 1516 System.out.print("路线为:"+line1+"->"); 1517 route="路线为:"+line1+"->"; 1518 } 1519 if(num1>num2) 1520 { 1521 String line2=getSitek2(num1, num2); 1522 System.out.print("路线为:"+line2+"->"); 1523 route="路线为:"+line2+"->"; 1524 } 1525 if(num3>num4) 1526 { 1527 String line1=getSiter3(num4, num3); 1528 System.out.print("(换乘)"+line1); 1529 route=route+"(换乘)"+line1; 1530 } 1531 if(num3<=num4) 1532 { 1533 String line2=getSitek3(num4, num3); 1534 System.out.print("(换乘)"+line2); 1535 route=route+"(换乘)"+line2; 1536 } 1537 } 1538 if(a[0]==3&&b[0]==2) 1539 { 1540 if(num1<=num2) 1541 { 1542 String line1=getSiter3(num1, num2); 1543 System.out.print("路线为:"+line1+"->"); 1544 route="路线为:"+line1+"->"; 1545 } 1546 if(num1>num2) 1547 { 1548 String line2=getSitek3(num1, num2); 1549 System.out.print("路线为:"+line2+"->"); 1550 route="路线为:"+line2+"->"; 1551 } 1552 if(num3>num4) 1553 { 1554 String line1=getSiter2(num4, num3); 1555 System.out.print("(换乘)"+line1); 1556 route=route+"(换乘)"+line1; 1557 } 1558 if(num3<=num4) 1559 { 1560 String line2=getSitek2(num4, num3); 1561 System.out.print("(换乘)"+line2); 1562 route=route+"(换乘)"+line2; 1563 } 1564 }//2-3 1565 if(a[0]==2&&b[0]==4) 1566 { 1567 if(num1<=num2) 1568 { 1569 String line1=getSiter2(num1, num2); 1570 System.out.print("路线为:"+line1+"->"); 1571 route="路线为:"+line1+"->"; 1572 } 1573 if(num1>num2) 1574 { 1575 String line2=getSitek2(num1, num2); 1576 System.out.print("路线为:"+line2+"->"); 1577 route="路线为:"+line2+"->"; 1578 } 1579 if(num3>num4) 1580 { 1581 String line1=getSiter4(num4, num3); 1582 System.out.print("(换乘)"+line1); 1583 route=route+"(换乘)"+line1; 1584 } 1585 if(num3<=num4) 1586 { 1587 String line2=getSitek4(num4, num3); 1588 System.out.print("(换乘)"+line2); 1589 route=route+"(换乘)"+line2; 1590 } 1591 } 1592 if(a[0]==4&&b[0]==2) 1593 { 1594 if(num1<=num2) 1595 { 1596 String line1=getSiter4(num1, num2); 1597 System.out.print("路线为:"+line1+"->"); 1598 route="路线为:"+line1+"->"; 1599 } 1600 if(num1>num2) 1601 { 1602 String line2=getSitek4(num1, num2); 1603 System.out.print("路线为:"+line2+"->"); 1604 route="路线为:"+line2+"->"; 1605 } 1606 if(num3>num4) 1607 { 1608 String line1=getSiter2(num4, num3); 1609 System.out.print("(换乘)"+line1); 1610 route=route+"(换乘)"+line1; 1611 } 1612 if(num3<=num4) 1613 { 1614 String line2=getSitek2(num4, num3); 1615 System.out.print("(换乘)"+line2); 1616 route=route+"(换乘)"+line2; 1617 } 1618 }//2-4 1619 if(a[0]==2&&b[0]==5) 1620 { 1621 if(num1<=num2) 1622 { 1623 String line1=getSiter2(num1, num2); 1624 System.out.print("路线为:"+line1+"->"); 1625 route="路线为:"+line1+"->"; 1626 } 1627 if(num1>num2) 1628 { 1629 String line2=getSitek2(num1, num2); 1630 System.out.print("路线为:"+line2+"->"); 1631 route="路线为:"+line2+"->"; 1632 } 1633 if(num3>num4) 1634 { 1635 String line1=getSiter5(num4, num3); 1636 System.out.print("(换乘)"+line1); 1637 route=route+"(换乘)"+line1; 1638 } 1639 if(num3<=num4) 1640 { 1641 String line2=getSitek5(num4, num3); 1642 System.out.print("(换乘)"+line2); 1643 route=route+"(换乘)"+line2; 1644 } 1645 } 1646 if(a[0]==5&&b[0]==2) 1647 { 1648 if(num1<=num2) 1649 { 1650 String line1=getSiter5(num1, num2); 1651 System.out.print("路线为:"+line1+"->"); 1652 route="路线为:"+line1+"->"; 1653 } 1654 if(num1>num2) 1655 { 1656 String line2=getSitek5(num1, num2); 1657 System.out.print("路线为:"+line2+"->"); 1658 route="路线为:"+line2+"->"; 1659 } 1660 if(num3>num4) 1661 { 1662 String line1=getSiter2(num4, num3); 1663 System.out.print("(换乘)"+line1); 1664 route=route+"(换乘)"+line1; 1665 } 1666 if(num3<=num4) 1667 { 1668 String line2=getSitek2(num4, num3); 1669 System.out.print("(换乘)"+line2); 1670 route=route+"(换乘)"+line2; 1671 } 1672 }//2-5 1673 if(a[0]==2&&b[0]==6) 1674 { 1675 if(num1<=num2) 1676 { 1677 String line1=getSiter2(num1, num2); 1678 System.out.print("路线为:"+line1+"->"); 1679 route="路线为:"+line1+"->"; 1680 } 1681 if(num1>num2) 1682 { 1683 String line2=getSitek2(num1, num2); 1684 System.out.print("路线为:"+line2+"->"); 1685 route="路线为:"+line2+"->"; 1686 } 1687 if(num3>num4) 1688 { 1689 String line1=getSiter6(num4, num3); 1690 System.out.print("(换乘)"+line1); 1691 route=route+"(换乘)"+line1; 1692 } 1693 if(num3<=num4) 1694 { 1695 String line2=getSitek6(num4, num3); 1696 System.out.print("(换乘)"+line2); 1697 route=route+"(换乘)"+line2; 1698 } 1699 } 1700 if(a[0]==6&&b[0]==2) 1701 { 1702 if(num1<=num2) 1703 { 1704 String line1=getSiter6(num1, num2); 1705 System.out.print("路线为:"+line1+"->"); 1706 route="路线为:"+line1+"->"; 1707 } 1708 if(num1>num2) 1709 { 1710 String line2=getSitek6(num1, num2); 1711 System.out.print("路线为:"+line2+"->"); 1712 route="路线为:"+line2+"->"; 1713 } 1714 if(num3>num4) 1715 { 1716 String line1=getSiter2(num4, num3); 1717 System.out.print("(换乘)"+line1); 1718 route=route+"(换乘)"+line1; 1719 } 1720 if(num3<=num4) 1721 { 1722 String line2=getSitek2(num4, num3); 1723 System.out.print("(换乘)"+line2); 1724 route=route+"(换乘)"+line2; 1725 } 1726 }//2-6 1727 if(a[0]==3&&b[0]==4) 1728 { 1729 if(num1<=num2) 1730 { 1731 String line1=getSiter3(num1, num2); 1732 System.out.print("路线为:"+line1+"->"); 1733 route="路线为:"+line1+"->"; 1734 } 1735 if(num1>num2) 1736 { 1737 String line2=getSitek3(num1, num2); 1738 System.out.print("路线为:"+line2+"->"); 1739 route="路线为:"+line2+"->"; 1740 } 1741 if(num3>num4) 1742 { 1743 String line1=getSiter4(num4, num3); 1744 System.out.print("(换乘)"+line1); 1745 route=route+"(换乘)"+line1; 1746 } 1747 if(num3<=num4) 1748 { 1749 String line2=getSitek4(num4, num3); 1750 System.out.print("(换乘)"+line2); 1751 route=route+"(换乘)"+line2; 1752 } 1753 } 1754 if(a[0]==4&&b[0]==3) 1755 { 1756 if(num1<=num2) 1757 { 1758 String line1=getSiter4(num1, num2); 1759 System.out.print("路线为:"+line1+"->"); 1760 route="路线为:"+line1+"->"; 1761 } 1762 if(num1>num2) 1763 { 1764 String line2=getSitek4(num1, num2); 1765 System.out.print("路线为:"+line2+"->"); 1766 route="路线为:"+line2+"->"; 1767 } 1768 if(num3>num4) 1769 { 1770 String line1=getSiter3(num4, num3); 1771 System.out.print("(换乘)"+line1); 1772 route=route+"(换乘)"+line1; 1773 } 1774 if(num3<=num4) 1775 { 1776 String line2=getSitek3(num4, num3); 1777 System.out.print("(换乘)"+line2); 1778 route=route+"(换乘)"+line2; 1779 } 1780 }//3-4 1781 if(a[0]==3&&b[0]==5) 1782 { 1783 if(num1<=num2) 1784 { 1785 String line1=getSiter3(num1, num2); 1786 System.out.print("路线为:"+line1+"->"); 1787 route="路线为:"+line1+"->"; 1788 } 1789 if(num1>num2) 1790 { 1791 String line2=getSitek3(num1, num2); 1792 System.out.print("路线为:"+line2+"->"); 1793 route="路线为:"+line2+"->"; 1794 } 1795 if(num3>num4) 1796 { 1797 String line1=getSiter5(num4, num3); 1798 System.out.print("(换乘)"+line1); 1799 route=route+"(换乘)"+line1; 1800 } 1801 if(num3<=num4) 1802 { 1803 String line2=getSitek5(num4, num3); 1804 System.out.print("(换乘)"+line2); 1805 route=route+"(换乘)"+line2; 1806 } 1807 } 1808 if(a[0]==5&&b[0]==3) 1809 { 1810 if(num1<=num2) 1811 { 1812 String line1=getSiter5(num1, num2); 1813 System.out.print("路线为:"+line1+"->"); 1814 route="路线为:"+line1+"->"; 1815 } 1816 if(num1>num2) 1817 { 1818 String line2=getSitek5(num1, num2); 1819 System.out.print("路线为:"+line2+"->"); 1820 route="路线为:"+line2+"->"; 1821 } 1822 if(num3>num4) 1823 { 1824 String line1=getSiter3(num4, num3); 1825 System.out.print("(换乘)"+line1); 1826 route=route+"(换乘)"+line1; 1827 } 1828 if(num3<=num4) 1829 { 1830 String line2=getSitek3(num4, num3); 1831 System.out.print("(换乘)"+line2); 1832 route=route+"(换乘)"+line2; 1833 } 1834 }//3-5 1835 if(a[0]==3&&b[0]==6) 1836 { 1837 if(num1<=num2) 1838 { 1839 String line1=getSiter3(num1, num2); 1840 System.out.print("路线为:"+line1+"->"); 1841 route="路线为:"+line1+"->"; 1842 } 1843 if(num1>num2) 1844 { 1845 String line2=getSitek3(num1, num2); 1846 System.out.print("路线为:"+line2+"->"); 1847 route="路线为:"+line2+"->"; 1848 } 1849 if(num3>num4) 1850 { 1851 String line1=getSiter6(num4, num3); 1852 System.out.print("(换乘)"+line1); 1853 route=route+"(换乘)"+line1; 1854 } 1855 if(num3<=num4) 1856 { 1857 String line2=getSitek6(num4, num3); 1858 System.out.print("(换乘)"+line2); 1859 route=route+"(换乘)"+line2; 1860 } 1861 } 1862 if(a[0]==6&&b[0]==3) 1863 { 1864 if(num1<=num2) 1865 { 1866 String line1=getSiter6(num1, num2); 1867 System.out.print("路线为:"+line1+"->"); 1868 route="路线为:"+line1+"->"; 1869 } 1870 if(num1>num2) 1871 { 1872 String line2=getSitek6(num1, num2); 1873 System.out.print("路线为:"+line2+"->"); 1874 route="路线为:"+line2+"->"; 1875 } 1876 if(num3>num4) 1877 { 1878 String line1=getSiter3(num4, num3); 1879 System.out.print("(换乘)"+line1); 1880 route=route+"(换乘)"+line1; 1881 } 1882 if(num3<=num4) 1883 { 1884 String line2=getSitek3(num4, num3); 1885 System.out.print("(换乘)"+line2); 1886 route=route+"(换乘)"+line2; 1887 } 1888 }//3-6 1889 if(a[0]==4&&b[0]==5) 1890 { 1891 if(num1<=num2) 1892 { 1893 String line1=getSiter4(num1, num2); 1894 System.out.print("路线为:"+line1+"->"); 1895 route="路线为:"+line1+"->"; 1896 } 1897 if(num1>num2) 1898 { 1899 String line2=getSitek4(num1, num2); 1900 System.out.print("路线为:"+line2+"->"); 1901 route="路线为:"+line2+"->"; 1902 } 1903 if(num3>num4) 1904 { 1905 String line1=getSiter5(num4, num3); 1906 System.out.print("(换乘)"+line1); 1907 route=route+"(换乘)"+line1; 1908 } 1909 if(num3<=num4) 1910 { 1911 String line2=getSitek5(num4, num3); 1912 System.out.print("(换乘)"+line2); 1913 route=route+"(换乘)"+line2; 1914 } 1915 } 1916 if(a[0]==5&&b[0]==4) 1917 { 1918 if(num1<=num2) 1919 { 1920 String line1=getSiter5(num1, num2); 1921 System.out.print("路线为:"+line1+"->"); 1922 route="路线为:"+line1+"->"; 1923 } 1924 if(num1>num2) 1925 { 1926 String line2=getSitek5(num1, num2); 1927 System.out.print("路线为:"+line2+"->"); 1928 route="路线为:"+line2+"->"; 1929 } 1930 if(num3>num4) 1931 { 1932 String line1=getSiter4(num4, num3); 1933 System.out.print("(换乘)"+line1); 1934 route=route+"(换乘)"+line1; 1935 } 1936 if(num3<=num4) 1937 { 1938 String line2=getSitek4(num4, num3); 1939 System.out.print("(换乘)"+line2); 1940 route=route+"(换乘)"+line2; 1941 } 1942 }//4-5 1943 if(a[0]==4&&b[0]==6) 1944 { 1945 if(num1<=num2) 1946 { 1947 String line1=getSiter4(num1, num2); 1948 System.out.print("路线为:"+line1+"->"); 1949 route="路线为:"+line1+"->"; 1950 } 1951 if(num1>num2) 1952 { 1953 String line2=getSitek4(num1, num2); 1954 System.out.print("路线为:"+line2+"->"); 1955 route="路线为:"+line2+"->"; 1956 } 1957 if(num3>num4) 1958 { 1959 String line1=getSiter6(num4, num3); 1960 System.out.print("(换乘)"+line1); 1961 route=route+"(换乘)"+line1; 1962 } 1963 if(num3<=num4) 1964 { 1965 String line2=getSitek6(num4, num3); 1966 System.out.print("(换乘)"+line2); 1967 route=route+"(换乘)"+line2; 1968 } 1969 } 1970 if(a[0]==6&&b[0]==4) 1971 { 1972 if(num1<=num2) 1973 { 1974 String line1=getSiter6(num1, num2); 1975 System.out.print("路线为:"+line1+"->"); 1976 route="路线为:"+line1+"->"; 1977 } 1978 if(num1>num2) 1979 { 1980 String line2=getSitek6(num1, num2); 1981 System.out.print("路线为:"+line2+"->"); 1982 route="路线为:"+line2+"->"; 1983 } 1984 if(num3>num4) 1985 { 1986 String line1=getSiter4(num4, num3); 1987 System.out.print("(换乘)"+line1); 1988 route=route+"(换乘)"+line1; 1989 } 1990 if(num3<=num4) 1991 { 1992 String line2=getSitek4(num4, num3); 1993 System.out.print("(换乘)"+line2); 1994 route=route+"(换乘)"+line2; 1995 } 1996 }//4-6 1997 if(a[0]==5&&b[0]==6) 1998 { 1999 if(num1<=num2) 2000 { 2001 String line1=getSiter5(num1, num2); 2002 System.out.print("路线为:"+line1+"->"); 2003 route="路线为:"+line1+"->"; 2004 } 2005 if(num1>num2) 2006 { 2007 String line2=getSitek5(num1, num2); 2008 System.out.print("路线为:"+line2+"->"); 2009 route="路线为:"+line2+"->"; 2010 } 2011 if(num3>num4) 2012 { 2013 String line1=getSiter6(num4, num3); 2014 System.out.print("(换乘)"+line1); 2015 route=route+"(换乘)"+line1; 2016 } 2017 if(num3<=num4) 2018 { 2019 String line2=getSitek6(num4, num3); 2020 System.out.print("(换乘)"+line2); 2021 route=route+"(换乘)"+line2; 2022 } 2023 } 2024 if(a[0]==6&&b[0]==5) 2025 { 2026 if(num1<=num2) 2027 { 2028 String line1=getSiter6(num1, num2); 2029 System.out.print("路线为:"+line1+"->"); 2030 route="路线为:"+line1+"->"; 2031 } 2032 if(num1>num2) 2033 { 2034 String line2=getSitek6(num1, num2); 2035 System.out.print("路线为:"+line2+"->"); 2036 route="路线为:"+line2+"->"; 2037 } 2038 if(num3>num4) 2039 { 2040 String line1=getSiter5(num4, num3); 2041 System.out.print("(换乘)"+line1); 2042 route=route+"(换乘)"+line1; 2043 } 2044 if(num3<=num4) 2045 { 2046 String line2=getSitek5(num4, num3); 2047 System.out.print("(换乘)"+line2); 2048 route=route+"(换乘)"+line2; 2049 } 2050 }//5-6 2051 return route; 2052 } 2053 2054 public int[] getviewnum(int a[],int b[],String c[],String start,String end) {//123456 2055 int []d=new int[4]; 2056 if(a[0]==1&&b[0]==2) 2057 { 2058 d[0]=getNum(start); 2059 d[1]=getNum2(end); 2060 d[2]=getNum(c[0]); 2061 d[3]=getNum2(c[0]); 2062 } 2063 if(a[0]==2&&b[0]==1) 2064 { 2065 d[0]=getNum2(start); 2066 d[1]=getNum(end); 2067 d[2]=getNum2(c[0]); 2068 d[3]=getNum(c[0]); 2069 }//1-2 2070 if(a[0]==1&&b[0]==3) 2071 { 2072 d[0]=getNum(start); 2073 d[1]=getNum3(end); 2074 d[2]=getNum(c[0]); 2075 d[3]=getNum3(c[0]); 2076 } 2077 if(a[0]==3&&b[0]==1) 2078 { 2079 d[0]=getNum3(start); 2080 d[1]=getNum(end); 2081 d[2]=getNum3(c[0]); 2082 d[3]=getNum(c[0]); 2083 }//1-3 2084 if(a[0]==1&&b[0]==4) 2085 { 2086 d[0]=getNum(start); 2087 d[1]=getNum4(end); 2088 d[2]=getNum(c[0]); 2089 d[3]=getNum4(c[0]); 2090 } 2091 if(a[0]==4&&b[0]==1) 2092 { 2093 d[0]=getNum4(start); 2094 d[1]=getNum(end); 2095 d[2]=getNum4(c[0]); 2096 d[3]=getNum(c[0]); 2097 }//1-4 2098 if(a[0]==1&&b[0]==5) 2099 { 2100 d[0]=getNum(start); 2101 d[1]=getNum5(end); 2102 d[2]=getNum(c[0]); 2103 d[3]=getNum5(c[0]); 2104 } 2105 if(a[0]==5&&b[0]==1) 2106 { 2107 d[0]=getNum5(start); 2108 d[1]=getNum(end); 2109 d[2]=getNum5(c[0]); 2110 d[3]=getNum(c[0]); 2111 }//1-5 2112 if(a[0]==1&&b[0]==6) 2113 { 2114 d[0]=getNum(start); 2115 d[1]=getNum6(end); 2116 d[2]=getNum(c[0]); 2117 d[3]=getNum6(c[0]); 2118 } 2119 if(a[0]==6&&b[0]==1) 2120 { 2121 d[0]=getNum6(start); 2122 d[1]=getNum(end); 2123 d[2]=getNum6(c[0]); 2124 d[3]=getNum(c[0]); 2125 }//1-6 2126 if(a[0]==2&&b[0]==3) 2127 { 2128 d[0]=getNum2(start); 2129 d[1]=getNum3(end); 2130 d[2]=getNum2(c[0]); 2131 d[3]=getNum3(c[0]); 2132 } 2133 if(a[0]==3&&b[0]==2) 2134 { 2135 d[0]=getNum3(start); 2136 d[1]=getNum2(end); 2137 d[2]=getNum3(c[0]); 2138 d[3]=getNum2(c[0]); 2139 }//2-3 2140 if(a[0]==2&&b[0]==4) 2141 { 2142 d[0]=getNum2(start); 2143 d[1]=getNum4(end); 2144 d[2]=getNum2(c[0]); 2145 d[3]=getNum4(c[0]); 2146 } 2147 if(a[0]==4&&b[0]==2) 2148 { 2149 d[0]=getNum4(start); 2150 d[1]=getNum2(end); 2151 d[2]=getNum4(c[0]); 2152 d[3]=getNum2(c[0]); 2153 }//2-4 2154 if(a[0]==2&&b[0]==5) 2155 { 2156 d[0]=getNum2(start); 2157 d[1]=getNum5(end); 2158 d[2]=getNum2(c[0]); 2159 d[3]=getNum5(c[0]); 2160 } 2161 if(a[0]==5&&b[0]==2) 2162 { 2163 d[0]=getNum5(start); 2164 d[1]=getNum2(end); 2165 d[2]=getNum5(c[0]); 2166 d[3]=getNum2(c[0]); 2167 }//2-5 2168 if(a[0]==2&&b[0]==6) 2169 { 2170 d[0]=getNum2(start); 2171 d[1]=getNum6(end); 2172 d[2]=getNum2(c[0]); 2173 d[3]=getNum6(c[0]); 2174 } 2175 if(a[0]==6&&b[0]==2) 2176 { 2177 d[0]=getNum6(start); 2178 d[1]=getNum2(end); 2179 d[2]=getNum6(c[0]); 2180 d[3]=getNum2(c[0]); 2181 }//2-6 2182 if(a[0]==3&&b[0]==4) 2183 { 2184 d[0]=getNum3(start); 2185 d[1]=getNum4(end); 2186 d[2]=getNum3(c[0]); 2187 d[3]=getNum4(c[0]); 2188 } 2189 if(a[0]==4&&b[0]==3) 2190 { 2191 d[0]=getNum4(start); 2192 d[1]=getNum3(end); 2193 d[2]=getNum4(c[0]); 2194 d[3]=getNum3(c[0]); 2195 }//3-4 2196 if(a[0]==3&&b[0]==5) 2197 { 2198 d[0]=getNum3(start); 2199 d[1]=getNum5(end); 2200 d[2]=getNum3(c[0]); 2201 d[3]=getNum5(c[0]); 2202 } 2203 if(a[0]==5&&b[0]==3) 2204 { 2205 d[0]=getNum5(start); 2206 d[1]=getNum3(end); 2207 d[2]=getNum5(c[0]); 2208 d[3]=getNum3(c[0]); 2209 }//3-5 2210 if(a[0]==3&&b[0]==6) 2211 { 2212 d[0]=getNum3(start); 2213 d[1]=getNum6(end); 2214 d[2]=getNum3(c[0]); 2215 d[3]=getNum6(c[0]); 2216 } 2217 if(a[0]==6&&b[0]==3) 2218 { 2219 d[0]=getNum6(start); 2220 d[1]=getNum3(end); 2221 d[2]=getNum6(c[0]); 2222 d[3]=getNum3(c[0]); 2223 }//3-6 2224 if(a[0]==4&&b[0]==5) 2225 { 2226 d[0]=getNum4(start); 2227 d[1]=getNum5(end); 2228 d[2]=getNum4(c[0]); 2229 d[3]=getNum5(c[0]); 2230 } 2231 if(a[0]==5&&b[0]==4) 2232 { 2233 d[0]=getNum5(start); 2234 d[1]=getNum4(end); 2235 d[2]=getNum5(c[0]); 2236 d[3]=getNum4(c[0]); 2237 }//4-5 2238 if(a[0]==4&&b[0]==6) 2239 { 2240 d[0]=getNum4(start); 2241 d[1]=getNum6(end); 2242 d[2]=getNum4(c[0]); 2243 d[3]=getNum6(c[0]); 2244 } 2245 if(a[0]==6&&b[0]==4) 2246 { 2247 d[0]=getNum6(start); 2248 d[1]=getNum4(end); 2249 d[2]=getNum6(c[0]); 2250 d[3]=getNum4(c[0]); 2251 }//4-6 2252 if(a[0]==5&&b[0]==6) 2253 { 2254 d[0]=getNum5(start); 2255 d[1]=getNum6(end); 2256 d[2]=getNum5(c[0]); 2257 d[3]=getNum6(c[0]); 2258 } 2259 if(a[0]==6&&b[0]==5) 2260 { 2261 d[0]=getNum6(start); 2262 d[1]=getNum5(end); 2263 d[2]=getNum6(c[0]); 2264 d[3]=getNum5(c[0]); 2265 }//5-6 2266 return d; 2267 } 2268 public int[] getviewnum1(int a[],int b[],String c[],String start,String end) {//123456 2269 int []d=new int[4]; 2270 if(a[0]==1&&b[0]==2) 2271 { 2272 d[0]=getNum(start); 2273 d[1]=getNum2(end); 2274 d[2]=getNum(c[1]); 2275 d[3]=getNum2(c[1]); 2276 } 2277 if(a[0]==2&&b[0]==1) 2278 { 2279 d[0]=getNum2(start); 2280 d[1]=getNum(end); 2281 d[2]=getNum2(c[1]); 2282 d[3]=getNum(c[1]); 2283 }//1-2 2284 if(a[0]==1&&b[0]==5) 2285 { 2286 d[0]=getNum(start); 2287 d[1]=getNum5(end); 2288 d[2]=getNum(c[1]); 2289 d[3]=getNum5(c[1]); 2290 } 2291 if(a[0]==5&&b[0]==1) 2292 { 2293 d[0]=getNum5(start); 2294 d[1]=getNum(end); 2295 d[2]=getNum5(c[1]); 2296 d[3]=getNum(c[1]); 2297 }//1-5 2298 if(a[0]==3&&b[0]==6) 2299 { 2300 d[0]=getNum3(start); 2301 d[1]=getNum6(end); 2302 d[2]=getNum3(c[1]); 2303 d[3]=getNum6(c[1]); 2304 } 2305 if(a[0]==6&&b[0]==3) 2306 { 2307 d[0]=getNum6(start); 2308 d[1]=getNum3(end); 2309 d[2]=getNum6(c[1]); 2310 d[3]=getNum3(c[1]); 2311 }//3-6 2312 if(a[0]==4&&b[0]==5) 2313 { 2314 d[0]=getNum4(start); 2315 d[1]=getNum5(end); 2316 d[2]=getNum4(c[1]); 2317 d[3]=getNum5(c[1]); 2318 } 2319 if(a[0]==5&&b[0]==4) 2320 { 2321 d[0]=getNum5(start); 2322 d[1]=getNum4(end); 2323 d[2]=getNum5(c[1]); 2324 d[3]=getNum4(c[1]); 2325 }//4-5 2326 return d; 2327 } 2328 public String getjkl(int a,String start,String end) {//遍历链路 2329 String route=""; 2330 if(a==1) 2331 { 2332 int b=getNum(start); 2333 int c=getNum(end); 2334 if(b<=c) 2335 { 2336 System.out.println(getSiter1(b,c)); 2337 route=getSiter1(b,c); 2338 } 2339 if(b>c) 2340 { 2341 System.out.println(getSitek1(b,c)); 2342 route=getSitek1(b,c); 2343 } 2344 } 2345 if(a==2) 2346 { 2347 int b=getNum2(start); 2348 int c=getNum2(end); 2349 if(b<=c) 2350 { 2351 System.out.println(getSiter2(b,c)); 2352 route=getSiter2(b,c); 2353 } 2354 if(b>c) 2355 { 2356 System.out.println(getSitek2(b,c)); 2357 route=getSitek2(b,c); 2358 } 2359 } 2360 if(a==3) 2361 { 2362 int b=getNum3(start); 2363 int c=getNum3(end); 2364 if(b<=c) 2365 { 2366 System.out.println(getSiter3(b,c)); 2367 route=getSiter3(b,c); 2368 } 2369 if(b>c) 2370 { 2371 System.out.println(getSitek3(b,c)); 2372 route=getSitek3(b,c); 2373 } 2374 } 2375 if(a==4) 2376 { 2377 int b=getNum4(start); 2378 int c=getNum4(end); 2379 if(b<=c) 2380 { 2381 System.out.println(getSiter4(b,c)); 2382 route=getSiter4(b,c); 2383 } 2384 if(b>c) 2385 { 2386 System.out.println(getSitek4(b,c)); 2387 route=getSitek4(b,c); 2388 } 2389 } 2390 if(a==5) 2391 { 2392 int b=getNum5(start); 2393 int c=getNum5(end); 2394 if(b<=c) 2395 { 2396 System.out.println(getSiter5(b,c)); 2397 route=getSiter5(b,c); 2398 } 2399 if(b>c) 2400 { 2401 System.out.println(getSitek5(b,c)); 2402 route=getSitek5(b,c); 2403 } 2404 } 2405 if(a==6) 2406 { 2407 int b=getNum6(start); 2408 int c=getNum6(end); 2409 if(b<=c) 2410 { 2411 System.out.println(getSiter6(b,c)); 2412 route=getSiter6(b,c); 2413 } 2414 if(b>c) 2415 { 2416 System.out.println(getSitek6(b,c)); 2417 route=getSitek6(b,c); 2418 } 2419 } 2420 return route; 2421 } 2422 public String getdouble(int num1,int num2) {//换乘点之间的路线 2423 String gsite=""; 2424 String sql = "select * from huancheng"; 2425 Connection conn = DBUtil.getConn(); 2426 Statement state = null; 2427 ResultSet rs = null; 2428 try { 2429 state = conn.createStatement(); 2430 rs = state.executeQuery(sql); 2431 List<subway> list = new ArrayList<subway>(); 2432 while (rs.next()) { 2433 huancheng s=new huancheng(); 2434 s.setSite(rs.getString("gsite")); 2435 s.setSec(rs.getInt("sec")); 2436 s.setFirst(rs.getInt("first")); 2437 if(num1==s.getFirst()&&num2==s.getSec()) 2438 { 2439 gsite=s.getSite(); 2440 } 2441 } 2442 } catch (Exception e) { 2443 e.printStackTrace(); 2444 } finally { 2445 DBUtil.close(rs, state, conn); 2446 } 2447 2448 return gsite; 2449 } 2450 public String getdoublesite(int num1,int num2,String start,String end) {//一次换乘情况,且起始终点出现换乘站 2451 String route=""; 2452 if(num1==1&&num2==2) 2453 { 2454 int []a=new int[2]; 2455 int []b=new int[2]; 2456 a[1]=0;b[1]=0; 2457 a[0]=1; 2458 b[0]=2; 2459 System.out.println(a[0]+","+b[0]); 2460 int []d=new int[4]; 2461 String []c=new String[2]; 2462 c=getgline(a, b); 2463 d=getviewnum(a, b, c, start, end); 2464 route=getview(a, b, d[0], d[2],d[1],d[3]); 2465 if(c[1]!="") 2466 { 2467 String route1=""; 2468 System.out.println(""); 2469 System.out.print("第二条路线:"); 2470 c=getgline(a, b); 2471 d=getviewnum1(a, b, c, start, end); 2472 route=route+"**********"; 2473 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2474 route=route+"第二条路线:"+route1; 2475 } 2476 }//1-2 2477 if(num1==2&&num2==1) 2478 { 2479 int []a=new int[2]; 2480 int []b=new int[2]; 2481 a[1]=0;b[1]=0; 2482 a[0]=2; 2483 b[0]=1; 2484 System.out.println(a[0]+","+b[0]); 2485 int []d=new int[4]; 2486 String []c=new String[2]; 2487 c=getgline(a, b); 2488 d=getviewnum(a, b, c, start, end); 2489 route=getview(a, b, d[0], d[2],d[1],d[3]); 2490 if(c[1]!="") 2491 { 2492 String route1=""; 2493 System.out.println(""); 2494 System.out.print("第二条路线:"); 2495 c=getgline(a, b); 2496 d=getviewnum1(a, b, c, start, end); 2497 route=route+"**********"; 2498 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2499 route=route+"第二条路线:"+route1; 2500 } 2501 }//2-1 2502 if(num1==1&&num2==3) 2503 { 2504 int []a=new int[2]; 2505 int []b=new int[2]; 2506 a[1]=0;b[1]=0; 2507 a[0]=1; 2508 b[0]=3; 2509 System.out.println(a[0]+","+b[0]); 2510 int []d=new int[4]; 2511 String []c=new String[2]; 2512 c=getgline(a, b); 2513 d=getviewnum(a, b, c, start, end); 2514 route=getview(a, b, d[0], d[2],d[1],d[3]); 2515 if(c[1]!="") 2516 { 2517 String route1=""; 2518 System.out.println(""); 2519 System.out.print("第二条路线:"); 2520 c=getgline(a, b); 2521 d=getviewnum1(a, b, c, start, end); 2522 route=route+"**********"; 2523 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2524 route=route+"第二条路线:"+route1; 2525 } 2526 }//1-3 2527 if(num1==3&&num2==1) 2528 { 2529 int []a=new int[2]; 2530 int []b=new int[2]; 2531 a[1]=0;b[1]=0; 2532 a[0]=3; 2533 b[0]=1; 2534 System.out.println(a[0]+","+b[0]); 2535 int []d=new int[4]; 2536 String []c=new String[2]; 2537 c=getgline(a, b); 2538 d=getviewnum(a, b, c, start, end); 2539 route=getview(a, b, d[0], d[2],d[1],d[3]); 2540 if(c[1]!="") 2541 { 2542 String route1=""; 2543 System.out.println(""); 2544 System.out.print("第二条路线:"); 2545 c=getgline(a, b); 2546 d=getviewnum1(a, b, c, start, end); 2547 route=route+"**********"; 2548 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2549 route=route+"第二条路线:"+route1; 2550 } 2551 }//3-1 2552 if(num1==1&&num2==4) 2553 { 2554 int []a=new int[2]; 2555 int []b=new int[2]; 2556 a[1]=0;b[1]=0; 2557 a[0]=1; 2558 b[0]=4; 2559 System.out.println(a[0]+","+b[0]); 2560 int []d=new int[4]; 2561 String []c=new String[2]; 2562 c=getgline(a, b); 2563 d=getviewnum(a, b, c, start, end); 2564 route=getview(a, b, d[0], d[2],d[1],d[3]); 2565 if(c[1]!="") 2566 { 2567 String route1=""; 2568 System.out.println(""); 2569 System.out.print("第二条路线:"); 2570 c=getgline(a, b); 2571 d=getviewnum1(a, b, c, start, end); 2572 route=route+"**********"; 2573 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2574 route=route+"第二条路线:"+route1; 2575 2576 } 2577 }//1-4 2578 if(num1==4&&num2==1) 2579 { 2580 int []a=new int[2]; 2581 int []b=new int[2]; 2582 a[1]=0;b[1]=0; 2583 a[0]=4; 2584 b[0]=1; 2585 System.out.println(a[0]+","+b[0]); 2586 int []d=new int[4]; 2587 String []c=new String[2]; 2588 c=getgline(a, b); 2589 d=getviewnum(a, b, c, start, end); 2590 route=getview(a, b, d[0], d[2],d[1],d[3]); 2591 if(c[1]!="") 2592 { 2593 String route1=""; 2594 System.out.println(""); 2595 System.out.print("第二条路线:"); 2596 c=getgline(a, b); 2597 d=getviewnum1(a, b, c, start, end); 2598 route=route+"**********"; 2599 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2600 route=route+"第二条路线:"+route1; 2601 } 2602 }//4-1 2603 if(num1==1&&num2==5) 2604 { 2605 int []a=new int[2]; 2606 int []b=new int[2]; 2607 a[1]=0;b[1]=0; 2608 a[0]=1; 2609 b[0]=5; 2610 System.out.println(a[0]+","+b[0]); 2611 int []d=new int[4]; 2612 String []c=new String[2]; 2613 c=getgline(a, b); 2614 d=getviewnum(a, b, c, start, end); 2615 route=getview(a, b, d[0], d[2],d[1],d[3]); 2616 if(c[1]!="") 2617 { 2618 String route1=""; 2619 System.out.println(""); 2620 System.out.print("第二条路线:"); 2621 c=getgline(a, b); 2622 d=getviewnum1(a, b, c, start, end); 2623 route=route+"**********"; 2624 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2625 route=route+"第二条路线:"+route1; 2626 } 2627 }//1-5 2628 if(num1==5&&num2==1) 2629 { 2630 int []a=new int[2]; 2631 int []b=new int[2]; 2632 a[1]=0;b[1]=0; 2633 a[0]=5; 2634 b[0]=1; 2635 System.out.println(a[0]+","+b[0]); 2636 int []d=new int[4]; 2637 String []c=new String[2]; 2638 c=getgline(a, b); 2639 d=getviewnum(a, b, c, start, end); 2640 route= getview(a, b, d[0], d[2],d[1],d[3]); 2641 if(c[1]!="") 2642 { 2643 String route1=""; 2644 System.out.println(""); 2645 System.out.print("第二条路线:"); 2646 c=getgline(a, b); 2647 d=getviewnum1(a, b, c, start, end); 2648 route=route+"**********"; 2649 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2650 route=route+"第二条路线:"+route1; 2651 } 2652 }//5-1 2653 if(num1==1&&num2==6) 2654 { 2655 int []a=new int[2]; 2656 int []b=new int[2]; 2657 a[1]=0;b[1]=0; 2658 a[0]=1; 2659 b[0]=6; 2660 System.out.println(a[0]+","+b[0]); 2661 int []d=new int[4]; 2662 String []c=new String[2]; 2663 c=getgline(a, b); 2664 d=getviewnum(a, b, c, start, end); 2665 route=getview(a, b, d[0], d[2],d[1],d[3]); 2666 if(c[1]!="") 2667 { 2668 String route1=""; 2669 System.out.println(""); 2670 System.out.print("第二条路线:"); 2671 c=getgline(a, b); 2672 d=getviewnum1(a, b, c, start, end); 2673 route=route+"**********"; 2674 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2675 route=route+"第二条路线:"+route1; 2676 } 2677 }//1-6 2678 if(num1==6&&num2==1) 2679 { 2680 int []a=new int[2]; 2681 int []b=new int[2]; 2682 a[1]=0;b[1]=0; 2683 a[0]=6; 2684 b[0]=1; 2685 System.out.println(a[0]+","+b[0]); 2686 int []d=new int[4]; 2687 String []c=new String[2]; 2688 c=getgline(a, b); 2689 d=getviewnum(a, b, c, start, end); 2690 route=getview(a, b, d[0], d[2],d[1],d[3]); 2691 if(c[1]!="") 2692 { 2693 String route1=""; 2694 System.out.println(""); 2695 System.out.print("第二条路线:"); 2696 c=getgline(a, b); 2697 d=getviewnum1(a, b, c, start, end); 2698 route=route+"**********"; 2699 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2700 route=route+"第二条路线:"+route1; 2701 } 2702 }//6-1 2703 if(num1==2&&num2==3) 2704 { 2705 int []a=new int[2]; 2706 int []b=new int[2]; 2707 a[1]=0;b[1]=0; 2708 a[0]=2; 2709 b[0]=3; 2710 System.out.println(a[0]+","+b[0]); 2711 int []d=new int[4]; 2712 String []c=new String[2]; 2713 c=getgline(a, b); 2714 d=getviewnum(a, b, c, start, end); 2715 route= getview(a, b, d[0], d[2],d[1],d[3]); 2716 if(c[1]!="") 2717 { 2718 String route1=""; 2719 System.out.println(""); 2720 System.out.print("第二条路线:"); 2721 c=getgline(a, b); 2722 d=getviewnum1(a, b, c, start, end); 2723 route=route+"**********"; 2724 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2725 route=route+"第二条路线:"+route1; 2726 } 2727 }//2-3 2728 if(num1==3&&num2==2) 2729 { 2730 int []a=new int[2]; 2731 int []b=new int[2]; 2732 a[1]=0;b[1]=0; 2733 a[0]=3; 2734 b[0]=2; 2735 System.out.println(a[0]+","+b[0]); 2736 int []d=new int[4]; 2737 String []c=new String[2]; 2738 c=getgline(a, b); 2739 d=getviewnum(a, b, c, start, end); 2740 route= getview(a, b, d[0], d[2],d[1],d[3]); 2741 if(c[1]!="") 2742 { 2743 String route1=""; 2744 System.out.println(""); 2745 System.out.print("第二条路线:"); 2746 c=getgline(a, b); 2747 d=getviewnum1(a, b, c, start, end); 2748 route=route+"**********"; 2749 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2750 route=route+"第二条路线:"+route1; 2751 } 2752 }//3-2 2753 if(num1==2&&num2==4) 2754 { 2755 int []a=new int[2]; 2756 int []b=new int[2]; 2757 a[1]=0;b[1]=0; 2758 a[0]=2; 2759 b[0]=4; 2760 System.out.println(a[0]+","+b[0]); 2761 int []d=new int[4]; 2762 String []c=new String[2]; 2763 c=getgline(a, b); 2764 d=getviewnum(a, b, c, start, end); 2765 route=getview(a, b, d[0], d[2],d[1],d[3]); 2766 if(c[1]!="") 2767 { 2768 String route1=""; 2769 System.out.println(""); 2770 System.out.print("第二条路线:"); 2771 c=getgline(a, b); 2772 d=getviewnum1(a, b, c, start, end); 2773 route=route+"**********"; 2774 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2775 route=route+"第二条路线:"+route1; 2776 } 2777 }//2-4 2778 if(num1==4&&num2==2) 2779 { 2780 int []a=new int[2]; 2781 int []b=new int[2]; 2782 a[1]=0;b[1]=0; 2783 a[0]=4; 2784 b[0]=2; 2785 System.out.println(a[0]+","+b[0]); 2786 int []d=new int[4]; 2787 String []c=new String[2]; 2788 c=getgline(a, b); 2789 d=getviewnum(a, b, c, start, end); 2790 route= getview(a, b, d[0], d[2],d[1],d[3]); 2791 if(c[1]!="") 2792 { 2793 String route1=""; 2794 System.out.println(""); 2795 System.out.print("第二条路线:"); 2796 c=getgline(a, b); 2797 d=getviewnum1(a, b, c, start, end); 2798 route=route+"**********"; 2799 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2800 route=route+"第二条路线:"+route1; 2801 } 2802 }//4-2 2803 if(num1==2&&num2==5) 2804 { 2805 int []a=new int[2]; 2806 int []b=new int[2]; 2807 a[1]=0;b[1]=0; 2808 a[0]=2; 2809 b[0]=5; 2810 System.out.println(a[0]+","+b[0]); 2811 int []d=new int[4]; 2812 String []c=new String[2]; 2813 c=getgline(a, b); 2814 d=getviewnum(a, b, c, start, end); 2815 route=getview(a, b, d[0], d[2],d[1],d[3]); 2816 if(c[1]!="") 2817 { 2818 String route1=""; 2819 System.out.println(""); 2820 System.out.print("第二条路线:"); 2821 c=getgline(a, b); 2822 d=getviewnum1(a, b, c, start, end); 2823 route=route+"**********"; 2824 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2825 route=route+"第二条路线:"+route1; 2826 } 2827 }//2-5 2828 if(num1==5&&num2==2) 2829 { 2830 int []a=new int[2]; 2831 int []b=new int[2]; 2832 a[1]=0;b[1]=0; 2833 a[0]=5; 2834 b[0]=2; 2835 System.out.println(a[0]+","+b[0]); 2836 int []d=new int[4]; 2837 String []c=new String[2]; 2838 c=getgline(a, b); 2839 d=getviewnum(a, b, c, start, end); 2840 route=getview(a, b, d[0], d[2],d[1],d[3]); 2841 if(c[1]!="") 2842 { 2843 String route1=""; 2844 System.out.println(""); 2845 System.out.print("第二条路线:"); 2846 c=getgline(a, b); 2847 d=getviewnum1(a, b, c, start, end); 2848 route=route+"**********"; 2849 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2850 route=route+"第二条路线:"+route1; 2851 } 2852 }//5-2 2853 if(num1==2&&num2==6) 2854 { 2855 int []a=new int[2]; 2856 int []b=new int[2]; 2857 a[1]=0;b[1]=0; 2858 a[0]=2; 2859 b[0]=6; 2860 System.out.println(a[0]+","+b[0]); 2861 int []d=new int[4]; 2862 String []c=new String[2]; 2863 c=getgline(a, b); 2864 d=getviewnum(a, b, c, start, end); 2865 route= getview(a, b, d[0], d[2],d[1],d[3]); 2866 if(c[1]!="") 2867 { 2868 String route1=""; 2869 System.out.println(""); 2870 System.out.print("第二条路线:"); 2871 c=getgline(a, b); 2872 d=getviewnum1(a, b, c, start, end); 2873 route=route+"**********"; 2874 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2875 route=route+"第二条路线:"+route1; 2876 } 2877 }//2-6 2878 if(num1==6&&num2==2) 2879 { 2880 int []a=new int[2]; 2881 int []b=new int[2]; 2882 a[1]=0;b[1]=0; 2883 a[0]=6; 2884 b[0]=2; 2885 System.out.println(a[0]+","+b[0]); 2886 int []d=new int[4]; 2887 String []c=new String[2]; 2888 c=getgline(a, b); 2889 d=getviewnum(a, b, c, start, end); 2890 route=getview(a, b, d[0], d[2],d[1],d[3]); 2891 if(c[1]!="") 2892 { 2893 String route1=""; 2894 System.out.println(""); 2895 System.out.print("第二条路线:"); 2896 c=getgline(a, b); 2897 d=getviewnum1(a, b, c, start, end); 2898 route=route+"**********"; 2899 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2900 route=route+"第二条路线:"+route1; 2901 } 2902 }//6-2 2903 if(num1==3&&num2==4) 2904 { 2905 int []a=new int[2]; 2906 int []b=new int[2]; 2907 a[1]=0;b[1]=0; 2908 a[0]=3; 2909 b[0]=4; 2910 System.out.println(a[0]+","+b[0]); 2911 int []d=new int[4]; 2912 String []c=new String[2]; 2913 c=getgline(a, b); 2914 d=getviewnum(a, b, c, start, end); 2915 route=getview(a, b, d[0], d[2],d[1],d[3]); 2916 if(c[1]!="") 2917 { 2918 String route1=""; 2919 System.out.println(""); 2920 System.out.print("第二条路线:"); 2921 c=getgline(a, b); 2922 d=getviewnum1(a, b, c, start, end); 2923 route=route+"**********"; 2924 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2925 route=route+"第二条路线:"+route1; 2926 } 2927 }//3-4 2928 if(num1==4&&num2==3) 2929 { 2930 int []a=new int[2]; 2931 int []b=new int[2]; 2932 a[1]=0;b[1]=0; 2933 a[0]=4; 2934 b[0]=3; 2935 System.out.println(a[0]+","+b[0]); 2936 int []d=new int[4]; 2937 String []c=new String[2]; 2938 c=getgline(a, b); 2939 d=getviewnum(a, b, c, start, end); 2940 route=getview(a, b, d[0], d[2],d[1],d[3]); 2941 if(c[1]!="") 2942 { 2943 String route1=""; 2944 System.out.println(""); 2945 System.out.print("第二条路线:"); 2946 c=getgline(a, b); 2947 d=getviewnum1(a, b, c, start, end); 2948 route=route+"**********"; 2949 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2950 route=route+"第二条路线:"+route1; 2951 } 2952 }//4-3 2953 if(num1==3&&num2==5) 2954 { 2955 int []a=new int[2]; 2956 int []b=new int[2]; 2957 a[1]=0;b[1]=0; 2958 a[0]=3; 2959 b[0]=5; 2960 System.out.println(a[0]+","+b[0]); 2961 int []d=new int[4]; 2962 String []c=new String[2]; 2963 c=getgline(a, b); 2964 d=getviewnum(a, b, c, start, end); 2965 route=getview(a, b, d[0], d[2],d[1],d[3]); 2966 if(c[1]!="") 2967 { 2968 String route1=""; 2969 System.out.println(""); 2970 System.out.print("第二条路线:"); 2971 c=getgline(a, b); 2972 d=getviewnum1(a, b, c, start, end); 2973 route=route+"**********"; 2974 route1=getview(a, b, d[0], d[2],d[1],d[3]); 2975 route=route+"第二条路线:"+route1; 2976 } 2977 }//3-5 2978 if(num1==5&&num2==3) 2979 { 2980 int []a=new int[2]; 2981 int []b=new int[2]; 2982 a[1]=0;b[1]=0; 2983 a[0]=5; 2984 b[0]=3; 2985 System.out.println(a[0]+","+b[0]); 2986 int []d=new int[4]; 2987 String []c=new String[2]; 2988 c=getgline(a, b); 2989 d=getviewnum(a, b, c, start, end); 2990 route=getview(a, b, d[0], d[2],d[1],d[3]); 2991 if(c[1]!="") 2992 { 2993 String route1=""; 2994 System.out.println(""); 2995 System.out.print("第二条路线:"); 2996 c=getgline(a, b); 2997 d=getviewnum1(a, b, c, start, end); 2998 route=route+"**********"; 2999 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3000 route=route+"第二条路线:"+route1; 3001 } 3002 }//5-3 3003 if(num1==3&&num2==6) 3004 { 3005 int []a=new int[2]; 3006 int []b=new int[2]; 3007 a[1]=0;b[1]=0; 3008 a[0]=3; 3009 b[0]=6; 3010 System.out.println(a[0]+","+b[0]); 3011 int []d=new int[4]; 3012 String []c=new String[2]; 3013 c=getgline(a, b); 3014 d=getviewnum(a, b, c, start, end); 3015 route= getview(a, b, d[0], d[2],d[1],d[3]); 3016 if(c[1]!="") 3017 { 3018 String route1=""; 3019 System.out.println(""); 3020 System.out.print("第二条路线:"); 3021 c=getgline(a, b); 3022 d=getviewnum1(a, b, c, start, end); 3023 route=route+"**********"; 3024 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3025 route=route+"第二条路线:"+route1; 3026 } 3027 }//3-6 3028 if(num1==6&&num2==3) 3029 { 3030 int []a=new int[2]; 3031 int []b=new int[2]; 3032 a[1]=0;b[1]=0; 3033 a[0]=6; 3034 b[0]=3; 3035 System.out.println(a[0]+","+b[0]); 3036 int []d=new int[4]; 3037 String []c=new String[2]; 3038 c=getgline(a, b); 3039 d=getviewnum(a, b, c, start, end); 3040 route=getview(a, b, d[0], d[2],d[1],d[3]); 3041 if(c[1]!="") 3042 { 3043 String route1=""; 3044 System.out.println(""); 3045 System.out.print("第二条路线:"); 3046 c=getgline(a, b); 3047 d=getviewnum1(a, b, c, start, end); 3048 route=route+"**********"; 3049 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3050 route=route+"第二条路线:"+route1; 3051 } 3052 }//6-3 3053 if(num1==4&&num2==5) 3054 { 3055 int []a=new int[2]; 3056 int []b=new int[2]; 3057 a[1]=0;b[1]=0; 3058 a[0]=4; 3059 b[0]=5; 3060 System.out.println(a[0]+","+b[0]); 3061 int []d=new int[4]; 3062 String []c=new String[2]; 3063 c=getgline(a, b); 3064 d=getviewnum(a, b, c, start, end); 3065 route=getview(a, b, d[0], d[2],d[1],d[3]); 3066 if(c[1]!="") 3067 { 3068 String route1=""; 3069 System.out.println(""); 3070 System.out.print("第二条路线:"); 3071 c=getgline(a, b); 3072 d=getviewnum1(a, b, c, start, end); 3073 route=route+"**********"; 3074 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3075 route=route+"第二条路线:"+route1; 3076 } 3077 }//4-5 3078 if(num1==5&&num2==4) 3079 { 3080 int []a=new int[2]; 3081 int []b=new int[2]; 3082 a[1]=0;b[1]=0; 3083 a[0]=5; 3084 b[0]=4; 3085 System.out.println(a[0]+","+b[0]); 3086 int []d=new int[4]; 3087 String []c=new String[2]; 3088 c=getgline(a, b); 3089 d=getviewnum(a, b, c, start, end); 3090 route=getview(a, b, d[0], d[2],d[1],d[3]); 3091 if(c[1]!="") 3092 { 3093 String route1=""; 3094 System.out.println(""); 3095 System.out.print("第二条路线:"); 3096 c=getgline(a, b); 3097 d=getviewnum1(a, b, c, start, end); 3098 route=route+"**********"; 3099 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3100 route=route+"第二条路线:"+route1; 3101 } 3102 }//5-4 3103 if(num1==4&&num2==6) 3104 { 3105 int []a=new int[2]; 3106 int []b=new int[2]; 3107 a[1]=0;b[1]=0; 3108 a[0]=4; 3109 b[0]=6; 3110 System.out.println(a[0]+","+b[0]); 3111 int []d=new int[4]; 3112 String []c=new String[2]; 3113 c=getgline(a, b); 3114 d=getviewnum(a, b, c, start, end); 3115 route=getview(a, b, d[0], d[2],d[1],d[3]); 3116 if(c[1]!="") 3117 { 3118 String route1=""; 3119 System.out.println(""); 3120 System.out.print("第二条路线:"); 3121 c=getgline(a, b); 3122 d=getviewnum1(a, b, c, start, end); 3123 route=route+"**********"; 3124 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3125 route=route+"第二条路线:"+route1; 3126 } 3127 }//4-6 3128 if(num1==6&&num2==4) 3129 { 3130 int []a=new int[2]; 3131 int []b=new int[2]; 3132 a[1]=0;b[1]=0; 3133 a[0]=6; 3134 b[0]=4; 3135 System.out.println(a[0]+","+b[0]); 3136 int []d=new int[4]; 3137 String []c=new String[2]; 3138 c=getgline(a, b); 3139 d=getviewnum(a, b, c, start, end); 3140 route=getview(a, b, d[0], d[2],d[1],d[3]); 3141 if(c[1]!="") 3142 { 3143 String route1=""; 3144 System.out.println(""); 3145 System.out.print("第二条路线:"); 3146 c=getgline(a, b); 3147 d=getviewnum1(a, b, c, start, end); 3148 route=route+"**********"; 3149 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3150 route=route+"第二条路线:"+route1; 3151 } 3152 }//6-4 3153 if(num1==5&&num2==6) 3154 { 3155 int []a=new int[2]; 3156 int []b=new int[2]; 3157 a[1]=0;b[1]=0; 3158 a[0]=5; 3159 b[0]=6; 3160 System.out.println(a[0]+","+b[0]); 3161 int []d=new int[4]; 3162 String []c=new String[2]; 3163 c=getgline(a, b); 3164 d=getviewnum(a, b, c, start, end); 3165 route=getview(a, b, d[0], d[2],d[1],d[3]); 3166 if(c[1]!="") 3167 { 3168 String route1=""; 3169 System.out.println(""); 3170 System.out.print("第二条路线:"); 3171 c=getgline(a, b); 3172 d=getviewnum1(a, b, c, start, end); 3173 route=route+"**********"; 3174 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3175 route=route+"第二条路线:"+route1; 3176 } 3177 }//5-6 3178 if(num1==6&&num2==5) 3179 { 3180 int []a=new int[2]; 3181 int []b=new int[2]; 3182 a[1]=0;b[1]=0; 3183 a[0]=6; 3184 b[0]=5; 3185 System.out.println(a[0]+","+b[0]); 3186 int []d=new int[4]; 3187 String []c=new String[2]; 3188 c=getgline(a, b); 3189 d=getviewnum(a, b, c, start, end); 3190 route=getview(a, b, d[0], d[2],d[1],d[3]); 3191 if(c[1]!="") 3192 { 3193 String route1=""; 3194 System.out.println(""); 3195 System.out.print("第二条路线:"); 3196 c=getgline(a, b); 3197 d=getviewnum1(a, b, c, start, end); 3198 route=route+"**********"; 3199 route1=getview(a, b, d[0], d[2],d[1],d[3]); 3200 route=route+"第二条路线:"+route1; 3201 } 3202 }//6-5 3203 return route; 3204 } 3205 }
1 Querj1.jsp 2 3 <%@ page language="java" contentType="text/html; charset=UTF-8" 4 pageEncoding="UTF-8"%> 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 6 <html> 7 <head> 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 9 10 <script src="jQuery/jquery-1.6.2.js"></script> 11 12 <link rel="stylesheet" type="text/css" href="css/index.css"> 13 <title>站点查询</title> 14 <!-- 图片缩放和固定div层拖动 --> 15 <style type="text/css"> 16 </style> 17 <% String data=(String)request.getAttribute("data"); 18 if(data!=null && !"".equals(data)){ 19 20 %> 21 <script type="text/javascript"> 22 alert("<%=data%>"); 23 </script> 24 <%} %> 25 </head> 26 <body> 27 <header> 28 <div class="logo">石家庄地铁站</div> 29 </header> 30 <form action="Servlet?method=chaxun" method="post" 31 onsubmit="return check()"> 32 <div id="left-panel" class="" style="height: 183px;"> 33 <div id="searchbox" class="clearfix"> 34 <div id="searchbox-container"> 35 <div id="metro-searchbox-content" 36 class="searchbox-content route-searchbox-content metroline"> 37 <div class="route-header"> 38 <!-- <div 39 class="searchbox-content-button left-button return-button loading-button" 40 data-title="返回" data-tooltip="2"></div> --> 41 <div class="searchbox-content-common route-tabs"> 42 <div class="tab-item metroline-tab" data-index="metroline"> 43 <i></i><span>地铁线路查询</span> 44 </div> 45 <div class="arrow-wrap"></div> 46 </div> 47 <div class="searchbox-content-button right-button cancel-button" 48 data-title="清空"></div> 49 </div> 50 <div class="routebox"> 51 <div 52 class="searchbox-content-common routebox-content metroline-content"> 53 <!-- <div class="routebox-revert" title="切换起终点"> 54 <input type="button" onclick="change()"> 55 <div class="routebox-revert-icon"></div> 56 </div> --> 57 <div class="routebox-inputs"> 58 <div class="routebox-input route-start"> 59 <div class="route-input-icon"></div> 60 <input id="sub_start_input" autocomplete="off" maxlength="256" 61 placeholder="输入起点" class="route-start-input" type="text" 62 id="start" name="start" value=""> 63 <div class="input-clear" title="清空"></div> 64 </div> 65 <div class="routebox-input route-end"> 66 <div class="route-input-icon"></div> 67 <input id="sub_end_input" autocomplete="off" maxlength="256" 68 placeholder="输入终点" class="route-end-input" type="text" 69 id="end" name="end" value=""> 70 <div class="input-clear" title="清空"></div> 71 </div> 72 </div> 73 </div> 74 <!-- <div 75 class="searchbox-content-common routebox-content metrostation-content"> 76 <div class="routebox-inputs"> 77 <div class="routebox-input route-start"> 78 <div class="route-input-icon"></div> 79 <input id="sub_station_input" autocomplete="off" 80 maxlength="256" placeholder="输入站点" class="route-start-input" 81 type="text" value=""> 82 <div class="input-clear" title="清空"></div> 83 </div> 84 </div> 85 </div> --> 86 </div> 87 </div> 88 </div> 89 <button id="search-button" data-title="搜索" data-tooltip="1"></button> 90 </div> 91 </div> 92 </form> 93 94 95 <div id='block1' 96 style='top: 0px; left: 0px;padding: 10px; position: absolute; width' 97 class="dragAble"> 98 <img src="images/石家庄地铁.jpg" id="images1" 99 onmousewheel="return bbimg(this)" ondblclick="realsize();" 100 style="top: 0px; left: 0px; position: relative;" width="auto" 101 height="auto"> 102 </div> 103 <!-- 控制文本 --> 104 <script type="text/javascript"> 105 function check() { 106 var start = document.getElementById("start"); 107 var end = document.getElementById("end"); 108 109 //非空 110 if (start.value == '') { 111 /* alert('起始站为空'); */ 112 start.focus(); 113 return false; 114 } 115 if (end.value == '') { 116 alert('终点站为空'); 117 end.focus(); 118 return false; 119 } 120 } 121 122 function change() { 123 var start = document.getElementById("start").value; 124 var end = document.getElementById("end").value; 125 126 document.getElementById("start").value = end; 127 document.getElementById("end").value = start; 128 } 129 </script> 130 131 <!-- 地图效果 --> 132 <script language="javascript" type="text/javascript"> 133 /*鼠标将图片在相应的div自由拖动*/ 134 drag = 0; 135 move = 0; 136 var ie = document.all; 137 var nn6 = document.getElementById && !document.all; 138 var isdrag = false; 139 var y, x; 140 var oDragObj; 141 var pic_width, pic_height, pic_zoom; 142 var divleft, divtop; 143 144 function moveMouse(e) { 145 if (isdrag) { 146 oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY 147 + event.clientY - y) 148 + "px"; 149 oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX 150 + event.clientX - x) 151 + "px"; 152 return false; 153 } 154 } 155 156 function initDrag(e) { 157 var oDragHandle = nn6 ? e.target : event.srcElement; 158 var topElement = "HTML"; 159 while (oDragHandle.tagName != topElement 160 && oDragHandle.className != "dragAble") { 161 oDragHandle = nn6 ? oDragHandle.parentNode 162 : oDragHandle.parentElement; 163 } 164 if (oDragHandle.className == "dragAble") { 165 isdrag = true; 166 oDragObj = oDragHandle; 167 nTY = parseInt(oDragObj.style.top + 0); 168 y = nn6 ? e.clientY : event.clientY; 169 nTX = parseInt(oDragObj.style.left + 0); 170 x = nn6 ? e.clientX : event.clientX; 171 document.onmousemove = moveMouse; 172 return false; 173 } 174 } 175 document.onmousedown = initDrag; 176 document.onmouseup = new Function("isdrag=false"); 177 178 $(document).ready(function() { 179 if (window.addEventListener) { 180 window.addEventListener('DOMMouseScroll', wheel, false);//给firefox添加鼠标滚动事件,因为火狐没有wheel事件 181 } 182 }); 183 184 function wheel(event) { 185 if (!event) /**//* For IE. */ 186 { 187 event = window.event; 188 } else if (event.detail) { 189 var height1 = $("#images1").attr("height"); 190 191 if (!height1) { 192 height1 = height1.substring(0, height1.length - 2); 193 194 } 195 var width1 = $("#images1").attr("width"); 196 197 if (!width1) { 198 width1 = width1.substring(0, width1.length - 2); 199 200 } 201 if (event.detail < 0) { 202 var temp1 = parseInt(height1) * 1.2; 203 var temp2 = parseInt(width1) * 1.2; 204 205 } else { 206 var temp1 = parseInt(height1) / 1.2; 207 var temp2 = parseInt(width1) / 1.2; 208 } 209 210 $("#images1").attr("height", temp1 + "px"); 211 212 $("#images1").attr("width", temp2 + "px"); 213 } 214 } 215 /*非Firefox的主流浏览器*/ 216 function bbimg(o) { 217 var zoom = parseInt(o.style.zoom, 10) || 100; 218 zoom += event.wheelDelta / 12; 219 if (zoom > 0) 220 o.style.zoom = zoom + '%'; 221 return false; 222 } 223 224 function realsize() { 225 $("#images1").attr("height", "auto"); 226 $("#images1").attr("width", "auto;"); 227 $("#images1").css("zoom", "100%"); 228 $("#block1").css("left", "0px"); 229 $("#block1").css("top", "0px"); 230 231 } 232 </script> 233 </body> 234 </html>
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 8 <script src="jQuery/jquery-1.6.2.js"></script> 9 10 <link rel="stylesheet" type="text/css" href="css/index.css"> 11 <title>站点查询</title> 12 <!-- 图片缩放和固定div层拖动 --> 13 <style type="text/css"> 14 </style> 15 <% String data=(String)request.getAttribute("data"); 16 if(data!=null && !"".equals(data)){ 17 18 %> 19 <script type="text/javascript"> 20 alert("<%=data%>"); 21 </script> 22 <%} %> 23 </head> 24 <body> 25 <header> 26 <div class="logo">石家庄地铁站</div> 27 </header> 28 <form action="Servlet?method=chaxun" method="post" 29 onsubmit="return check()"> 30 <div id="left-panel" class="" style="height: 183px;"> 31 <div id="searchbox" class="clearfix"> 32 <div id="searchbox-container"> 33 <div id="metro-searchbox-content" 34 class="searchbox-content route-searchbox-content metroline"> 35 <div class="route-header"> 36 <!-- <div 37 class="searchbox-content-button left-button return-button loading-button" 38 data-title="返回" data-tooltip="2"></div> --> 39 <div class="searchbox-content-common route-tabs"> 40 <div class="tab-item metroline-tab" data-index="metroline"> 41 <i></i><span>地铁线路查询</span> 42 </div> 43 <div class="arrow-wrap"></div> 44 </div> 45 <div class="searchbox-content-button right-button cancel-button" 46 data-title="清空"></div> 47 </div> 48 <div class="routebox"> 49 <div 50 class="searchbox-content-common routebox-content metroline-content"> 51 <!-- <div class="routebox-revert" title="切换起终点"> 52 <input type="button" onclick="change()"> 53 <div class="routebox-revert-icon"></div> 54 </div> --> 55 <div class="routebox-inputs"> 56 <div class="routebox-input route-start"> 57 <div class="route-input-icon"></div> 58 <input id="sub_start_input" autocomplete="off" maxlength="256" 59 placeholder="输入起点" class="route-start-input" type="text" 60 id="start" name="start" value=""> 61 <div class="input-clear" title="清空"></div> 62 </div> 63 <div class="routebox-input route-end"> 64 <div class="route-input-icon"></div> 65 <input id="sub_end_input" autocomplete="off" maxlength="256" 66 placeholder="输入终点" class="route-end-input" type="text" 67 id="end" name="end" value=""> 68 <div class="input-clear" title="清空"></div> 69 </div> 70 </div> 71 </div> 72 <!-- <div 73 class="searchbox-content-common routebox-content metrostation-content"> 74 <div class="routebox-inputs"> 75 <div class="routebox-input route-start"> 76 <div class="route-input-icon"></div> 77 <input id="sub_station_input" autocomplete="off" 78 maxlength="256" placeholder="输入站点" class="route-start-input" 79 type="text" value=""> 80 <div class="input-clear" title="清空"></div> 81 </div> 82 </div> 83 </div> --> 84 </div> 85 </div> 86 </div> 87 <button id="search-button" data-title="搜索" data-tooltip="1"></button> 88 </div> 89 </div> 90 </form> 91 92 93 <div id='block1' 94 style='top: 0px; left: 0px;padding: 10px; position: absolute; width' 95 class="dragAble"> 96 <img src="images/石家庄地铁.jpg" id="images1" 97 onmousewheel="return bbimg(this)" ondblclick="realsize();" 98 style="top: 0px; left: 0px; position: relative;" width="auto" 99 height="auto"> 100 </div> 101 <!-- 控制文本 --> 102 <script type="text/javascript"> 103 function check() { 104 var start = document.getElementById("start"); 105 var end = document.getElementById("end"); 106 107 //非空 108 if (start.value == '') { 109 /* alert('起始站为空'); */ 110 start.focus(); 111 return false; 112 } 113 if (end.value == '') { 114 alert('终点站为空'); 115 end.focus(); 116 return false; 117 } 118 } 119 120 function change() { 121 var start = document.getElementById("start").value; 122 var end = document.getElementById("end").value; 123 124 document.getElementById("start").value = end; 125 document.getElementById("end").value = start; 126 } 127 </script> 128 129 <!-- 地图效果 --> 130 <script language="javascript" type="text/javascript"> 131 /*鼠标将图片在相应的div自由拖动*/ 132 drag = 0; 133 move = 0; 134 var ie = document.all; 135 var nn6 = document.getElementById && !document.all; 136 var isdrag = false; 137 var y, x; 138 var oDragObj; 139 var pic_width, pic_height, pic_zoom; 140 var divleft, divtop; 141 142 function moveMouse(e) { 143 if (isdrag) { 144 oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY 145 + event.clientY - y) 146 + "px"; 147 oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX 148 + event.clientX - x) 149 + "px"; 150 return false; 151 } 152 } 153 154 function initDrag(e) { 155 var oDragHandle = nn6 ? e.target : event.srcElement; 156 var topElement = "HTML"; 157 while (oDragHandle.tagName != topElement 158 && oDragHandle.className != "dragAble") { 159 oDragHandle = nn6 ? oDragHandle.parentNode 160 : oDragHandle.parentElement; 161 } 162 if (oDragHandle.className == "dragAble") { 163 isdrag = true; 164 oDragObj = oDragHandle; 165 nTY = parseInt(oDragObj.style.top + 0); 166 y = nn6 ? e.clientY : event.clientY; 167 nTX = parseInt(oDragObj.style.left + 0); 168 x = nn6 ? e.clientX : event.clientX; 169 document.onmousemove = moveMouse; 170 return false; 171 } 172 } 173 document.onmousedown = initDrag; 174 document.onmouseup = new Function("isdrag=false"); 175 176 $(document).ready(function() { 177 if (window.addEventListener) { 178 window.addEventListener('DOMMouseScroll', wheel, false);//给firefox添加鼠标滚动事件,因为火狐没有wheel事件 179 } 180 }); 181 182 function wheel(event) { 183 if (!event) /**//* For IE. */ 184 { 185 event = window.event; 186 } else if (event.detail) { 187 var height1 = $("#images1").attr("height"); 188 189 if (!height1) { 190 height1 = height1.substring(0, height1.length - 2); 191 192 } 193 var width1 = $("#images1").attr("width"); 194 195 if (!width1) { 196 width1 = width1.substring(0, width1.length - 2); 197 198 } 199 if (event.detail < 0) { 200 var temp1 = parseInt(height1) * 1.2; 201 var temp2 = parseInt(width1) * 1.2; 202 203 } else { 204 var temp1 = parseInt(height1) / 1.2; 205 var temp2 = parseInt(width1) / 1.2; 206 } 207 208 $("#images1").attr("height", temp1 + "px"); 209 210 $("#images1").attr("width", temp2 + "px"); 211 } 212 } 213 /*非Firefox的主流浏览器*/ 214 function bbimg(o) { 215 var zoom = parseInt(o.style.zoom, 10) || 100; 216 zoom += event.wheelDelta / 12; 217 if (zoom > 0) 218 o.style.zoom = zoom + '%'; 219 return false; 220 } 221 222 function realsize() { 223 $("#images1").attr("height", "auto"); 224 $("#images1").attr("width", "auto;"); 225 $("#images1").css("zoom", "100%"); 226 $("#block1").css("left", "0px"); 227 $("#block1").css("top", "0px"); 228 229 } 230 </script> 231 </body> 232 </html>
四、实验截图
不换乘情况:
换乘情况:
五、结果分析
在本次结对开发中,我们的代码实现都很繁琐,都是在使用最直白的表现方式,所以在功能实现上不是很完全,其次在实验中没有考虑到最少换乘和最少站的情况.
在我们的实验中,只要是能直接到达的一定是直接到达的,所以说关于换乘的情况比较少,这点在实际中是不太试用的,可以参照百度地图的方式进行编写.
另外,地图界面是从百度地图上参考的.