• 结队开发地铁路线


    数据库创建了七个表,分别储存七条路线,基本能完成一条线路上以及换乘一次的情况,但是界面还需要完善而且没有做出来换乘两次以及对上面的所有情况进行计算所经过的路程然后比较出最小值才能计算出最短路径,最终我们将jsp页面 变为了jsp+javabean+severlt我们最终添加票价系统,并且为我们的地图添加了一个地图放大缩小界面<script type="text/javascript">
    var myimage = document.getElementById("img");  
    if (myimage.addEventListener) {  
        // IE9, Chrome, Safari, Opera  
        myimage.addEventListener("mousewheel", MouseWheelHandler, false);
        // Firefox  
        myimage.addEventListener("DOMMouseScroll", MouseWheelHandler, false);  
    }  
    // IE 6/7/8  
    else myimage.attachEvent("onmousewheel", MouseWheelHandler); 
    function MouseWheelHandler(e) {  
        var e = window.event || e; // old IE support  
        var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
        myimage.style.width = Math.max(50, Math.min(800, myimage.width + (30 * delta))) + "px";  
        myimage.style.height = Math.max(50, Math.min(800, myimage.width + (30 * delta))) + "px";
        return false;  

    其他的没什么变化

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    <style type="text/css">
            *  {margin:0;padding:0;}/*去掉页面样式*/
               body{color:white;}
              .content{
                  background-color:black;
                left:0;
                max- 100%;
                 height:120px;
                 /*margin-top:00px;
                  margin-left:00px;
                  margin-right:600px;
                overflow:hidden;/*隐藏滚动条*/
            margin:50 auto;/*设置上右下左,居中显示*/
              
             }
               .content1{
                  background-color:white;
                left:0;
                max- 100%;
                 height:60px;
                 /*margin-top:00px;
                  margin-left:00px;
                  margin-right:600px;
                overflow:hidden;/*隐藏滚动条*/
            margin:50 auto;/*设置上右下左,居中显示*/
              
             }
             .content2{
                  background-color:green;
                left:0;
                max- 100%;
                 height:60px;
                 /*margin-top:00px;
                  margin-left:00px;
                  margin-right:600px;
                overflow:hidden;/*隐藏滚动条*/
            margin:50 auto;/*设置上右下左,居中显示*/
             background:blue;
              
             }
             .main{
                text-align:center;/*文本居中*/
                 100%;
                 height:400px;
                 padding:100px 0px;/*上下80px,左右为0*/
                 background:gray;/*验证div的位置*/
                margin:0 auto;/*设置上右下左,居中显示*/
               
             }
             .content h1{
                 font-family:"LiSu";/*设置字体*/
                 font-size:30px;/*设置字体大小*/
                 font-weight:2px;/*调整字体粗细*/
                 color: white;/*设置字的颜色*/
            }
             .content h2{
                 font-family:"YOUYUAN";/*设置字体*/
                 font-size:25px;/*设置字体大小*/
                 font-weight:1px;/*调整字体粗细*/
                 color: green;/*设置字的颜色*/
            }
            .content h3{
                 font-family:"SONGTI";/*设置字体*/
                 font-size:20px;/*设置字体大小*/
                 font-weight:0.5px;/*调整字体粗细*/
                 color: purple;/*设置字的颜色*/
            }
            .content2 h5{
                   font-family:"宋体";/*设置字体*/
                 font-size:25px;/*设置字体大小*/
                 font-weight:2px;/*调整字体粗细*/
                 color: white;/*设置字的颜色*/
            }   
            #slideShowContainer{
        425px;
        height: 325px;
        margin-top: 10px;
        margin-left: 10px;
        overflow: hidden;
        position: relative;
    }
    #slideShowContainer img{
        425px;
        height: 325px;
        transition: all 0.6s;
    }
    #slideShowContainer img:hover{
        transform: scale(1.07);
    }
    #picUl{
        list-style: none;
    }
    #dotUl{    
        list-style: none;
        display: flex;
        flex-direction: row;
        position: absolute;  //使用绝对布局,固定于左下角
        right: 21px;
        bottom: 15px;
        z-index: 2;  //通过设置z-index的值大于#titleDiv中z-index的值,使其浮在标题栏的上方
        }
    #titleDiv{
        position: absolute;
        100%;
        height: 42px;
        bottom: 0px;
        left: 0px;
        background-color: #000000;
        opacity:0.6;  //设置透明度,实现标题栏半透明效果
        z-index: 1;
    }
    #titleDiv>span{
        line-height: 42px;
        color: #FFFFFF;
        margin-left: 20px;
        270px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #titleDiv>span>a{
        color: #FFFFFF;
    }
    .selected{
        12px;
        height: 12px;
        background-color: #FFFFFF;
        color: transparent;
         margin-left: 9px;
    }
    .unselected{
        12px;
        height: 12px;
        background-color: #0069AD;
        color: transparent;
        margin-left: 9px;
    }
    .hide{
        display: none;
    }
    .show{
        display: block;
    }
         </style>
    </head>
    <body>
    <div class="content">
      <table>
       <tr>
        <td width="100px"><h1>石家庄</h1></td>
                        <td width="200"><h2>地铁服务系统</h2></td>
        <td width="60px"><a href="1.html"><h3>首页</h3></a></td>
                        <td width="80px"><a href="C:Users97890Desktop8.html"><h3>关于地铁乘车信息</h3></a></td>
                        <td width="60px"><a href="https://www.cnblogs.com/"><h3>确认提交您的选择路线</h3></a></td>
                        <td width="60px"><a href="https://www.cnblogs.com/"><h3>留言</h3></a></td>
                        <td width="60px"><a href="https://www.cnblogs.com/"><select name="select" id="" display:none><option value="" display:none><h3>娱乐</h3></option><option value=""><h3>音乐鉴赏</h3></option><option value=""><h3>游戏</h3></option></select></a></td>
                       
       </tr>
      </table>
     </div>
     <hr>
              <div class="content1">
               <table>
                <tr>
                 <td width="1500px"><img src="C:Users97890DesktopJAVA地铁工程图片/1.jpg" width="600" height="60px" alt=""></td>
                 <td><a href="C:Users97890DesktopJAVA地铁工程图片/1.jpg"><img src="C:Users97890DesktopJAVA地铁工程图片/1.jpg" width="600px" height="60px" alt=""></a></td>
                </tr>
               </table>
              </div>
              <hr>
     <div class="main">
     <table>
      <tr>
       <td width="1000px"><img src="C:Users97890DesktopJAVA地铁工程图片/3.jpg" width="1000px" height="500px" alt=""/></td>
     
       <td width="200px">
       <form action="ceshi.jsp" method="post">
        请输入起始站线路:<input type="text" name="number1"/><br>
        请输入起始站:<input type="text" name="name1"/><br>
        请输入终点站线路:<input type="text" name="number2"/><br>
        请输入终点站:<input type="text" name="name2"/><br>
        <input type="submit" value="查询自己的路线">
       </form></td>
      </tr>
     </table>
     
     </div>
     
     
    </body>
    </html>
    show。jsp
    <%@ page language="java" contentType="text/html; charset=utf-8"%>
     <%@ page import="java.sql.*" %>
      <%@ page import="地铁.*" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>获得站名</title>
    </head>
    <body>
    <%
     String url="jdbc:mysql://localhost:3306/road";
     String user="root";
     String password="root";
     String[] aaa=new String[158];
     Connection conn=null;
      try{Class.forName("com.mysql.jdbc.Driver");//加载JDBC程序驱动
      conn =DriverManager.getConnection(url,user,password);
      
      }catch (ClassNotFoundException e){
       out.println("加载驱动失败");          //处理ClassNotFoundException的异常
      }catch(SQLException e){
       out.println("连接MYSQL数据库失败");
      }
      try{
       //创建语句对象Statement
       Statement stmt=conn.createStatement();
       //站名
       String queryAll="SELECT name FROM lineone;";
       //执行查询
       ResultSet rs=stmt.executeQuery(queryAll);
       int i=0;
       while(rs.next()){
        //获得站名
        aaa[i]=rs.getString(1);
        i++;
       }
      }catch(SQLException e){
       out.println("查询所有站点失败");
      }
      for(int i=0;i<158;i++){
       out.println("""+aaa[i]+"""+",");
       
      }
      line c=new line();
      response.setContentType("text/html;charset=utf-8");
     request.setCharacterEncoding("utf-8");
        String name1=request.getParameter("name1");
        String name2=request.getParameter("name2");
        int a = Integer.parseInt(request.getParameter("number1"));
       int b = Integer.parseInt(request.getParameter("number2"));
       //if(a==5){
      //  out.println("大声告诉我");
       //}
       //if(b==1){
     //   out.println("b==1"+name1+name2);
       //}
      // out.println(name1);
        c.nu(name1,name2,a,b,aaa);
    %>
    </body>
    </html>
    cishi.java
    package 地铁;
    import 地铁.line;
    public class line {
     @SuppressWarnings("null")
     public void nu(String a,String b,int line1,int line2,String[] aaa) {
      String aa[]=new String[158];
      for(int i=0;i<158;i++) {
       aa[i]=aaa[i]; 
      }
      int qizhanid=0;  //起点站和终点站记录
      int zhongzhanid=0;
      int change1=0;//换成站id记录
      int change2=0;
      int number1=0;
      int number2=0;
      int n1=0;
      int n2=0;
      if(line1!=line2) {
      switch(line1) {
      case 1:
       n1=29;
      break;
      case 2:
       n1=37;
      break;
      case 3:
       n1=34;
      break;
      case 4:
       n1=18;
      break;
      case 5:
       n1=21;
      break;
      case 6:
       n1=19;
      break;
      }
      switch(line2) {
      case 1:
       n2=29;
      break;
      case 2:
       n2=37;
      break;
      case 3:
       n2=34;
      break;
      case 4:
       n2=18;
      break;
      case 5:
       n2=21;
      break;
      case 6:
       n2=19;
      break;
      }
      
      String zancun1[]=new String[n1] ;
      String zancun2[]=new String[n2] ;
      
      //将两个起始站和终点站路线分别存在不同的数组zancun1和zancun2中
      switch (line1) {
      case 1:
      for(int i=0;i<29;i++)
      {
                zancun1[i]=aa[i];
       
      }
      break;
      case 2:
       for(int i=0;i<37;i++)
       {
        zancun1[i]=aa[i+29];
        
       }
       break;
      case 3:
       for(int i=0;i<34;i++)
       {
                 zancun1[i]=aa[i+66];
        
       }
       break;
         case 4:
        for(int i=0;i<18;i++)
        {
         zancun1[i]=aa[i+100];
         
        }
        break;
         case 5:
        for(int i=0;i<21;i++)
        {
                  zancun1[i]=aa[i+118];
         
        }
        break;
      case 6:
        for(int i=0;i<19;i++)
        {
          zancun1[i]=aa[i+139];
          
        }
         break;
      }
      switch (line2) {
      case 1:
       for(int i=0;i<29;i++)
       {
                 zancun2[i]=aa[i];
        
       }
       break;
       case 2:
        for(int i=0;i<37;i++)
        {
         zancun2[i]=aa[i+29];
         
        }
        break;
       case 3:
        for(int i=0;i<34;i++)
        {
                  zancun2[i]=aa[i+66];
         
        }
        break;
          case 4:
         for(int i=0;i<18;i++)
         {
          zancun2[i]=aa[i+100];
          
         }
         break;
          case 5:
         for(int i=0;i<21;i++)
         {
                   zancun2[i]=aa[i+118];
          
         }
         break;
       case 6:
         for(int i=0;i<19;i++)
         {
           zancun2[i]=aa[i+139];
           
         }
          break;
      }
      //获得地铁路线的换乘车站change1和change2
      outer:for(int i=0;i<zancun1.length;i++) {
       for(int j1=0;j1<zancun2.length;j1++) {
        if(zancun1[i].equals(zancun2[j1])){
         change1=i;
         change2=j1;
         break outer;
        }
       }
        
      }
     //for循环实现对起始站换乘站及以前站的输出 
       //获得起始站id
       for(int i=0;i<zancun1.length;i++) {
        if(zancun1[i].equals(a)) {
         qizhanid=i;
         break;
        }
               }
       //两中情况判断起始站到中转站路径
      if(qizhanid<=change1) {
       for(int i=qizhanid;i<=change1;i++) {
       System.out.println(zancun1[i]+"   ");
       if(i==change1) {
        System.out.println("***次站为换乘车站");
       }
       } 
            }else {
       for(int i=qizhanid;i>=change1;i--) {
       System.out.println(zancun1[i]+"   ");
       if(i==change1) {
        System.out.println("***次站为换乘车站");
       }
              }       
                  }
      
               
      
      //for循环实现换乘车站从中转路径到终点站的输出
       //获得终点站zhongzhanid
       for(int i=0;i<zancun2.length;i++) {
        if(zancun2[i].equals(b)) {
         zhongzhanid=i;
         break;
        }
               }
       //两中情况判断起始站到中转站路径
      if(zhongzhanid<=change2) {
       for(int i=change2-1;i>=zhongzhanid;i--) {
       System.out.println(zancun2[i]+"   ");
       } 
            }else {
       for(int i=change2+1;i<=zhongzhanid;i++) {
       System.out.println(zancun2[i]+"  ");
              }       
                  }
                } 
      else if(line1==line2)
         //在同一条线上的直线输出       
                {
       switch(line1) {
       case 1:
        n1=29;
       break;
       case 2:
        n1=37;
       break;
       case 3:
        n1=34;
       break;
       case 4:
        n1=18;
       break;
       case 5:
        n1=21;
       break;
       case 6:
        n1=19;
       break;
       }
       String zancun1[]=new String[n1] ;
          switch (line1) {
          case 1:
          for(int i=0;i<29;i++)
          {
                    zancun1[i]=aa[i];
           
          }
          break;
          case 2:
           for(int i=0;i<37;i++)
           {
            zancun1[i]=aa[i+29];
            
           }
           break;
          case 3:
           for(int i=0;i<34;i++)
           {
                     zancun1[i]=aa[i+66];
            
           }
           break;
             case 4:
            for(int i=0;i<18;i++)
            {
             zancun1[i]=aa[i+100];
             
            }
            break;
             case 5:
            for(int i=0;i<21;i++)
            {
                      zancun1[i]=aa[i+118];
             
            }
            break;
          case 6:
            for(int i=0;i<19;i++)
            {
              zancun1[i]=aa[i+139];
              
            }
             break;
            } 
        //获得起始站id
         for(int i=0;i<zancun1.length;i++) {
          if(zancun1[i].equals(a)) {
           qizhanid=i;
           break;
          }
         }
        //获得终站id
          for(int i=0;i<zancun1.length;i++) {
            if(zancun1[i].equals(b)) {
           zhongzhanid=i;
          break;
           }          
                      }
          //判断起站和中站的起始顺序
          if(qizhanid<=zhongzhanid) {
           for(int i=qizhanid;i<=zhongzhanid;i++) {   //起始站在终点站前面
            System.out.println(zancun1[i]);
           }
            }else {
          //在一个路线上直线输出路线
          for(int i=qizhanid;i>=zhongzhanid;i--) {
           System.out.println(zancun1[i]);
          }}
             }         
     }      }
     
     
  • 相关阅读:
    java.lang.ClassCastException: java.util.HashMap$Values cannot be cast to java.util.List 转换异常
    React Swiper轮播图(二)
    超详细带你入门开发一个超实用的浏览器插件
    手臂太细如何增加纬度?这5个手臂锻炼动作,让你的手臂变粗壮
    2021百度世界大会精华总结(AI应用向)
    1、saltstack 安装部署
    MySQL的varchar(10)能存多少个汉字
    学习资料总结
    基于Spark的数据工厂(Data Factory):从设计到实现
    IntelliJ IDEA创建maven web项目(IDEA新手适用)
  • 原文地址:https://www.cnblogs.com/yang-qiu/p/10651750.html
Copyright © 2020-2023  润新知