zoukankan      html  css  js  c++  java
  • 第二周星期一

    1、新增代码设计

    * FileName:FileIO.java
    * 处理文件的读写
    */
    public class FileIO {

    public static String READ_PATH; //读取路径
    public static String WRITE_PATH; //写入路径

    /**
    * 读取文件初始化地铁线路
    */
    public static void readSubway(List < Station > map) throws IOException {
    File readfile = new File(READ_PATH);
    BufferedReader reader = new BufferedReader(new FileReader(readfile));
    String tempString = null;
    while ((tempString = reader.readLine()) != null) {
    int trim = tempString.indexOf(' ');
    String lineNo = tempString.substring(0, trim);
    tempString = tempString.substring(trim + 1);
    String[] stations = tempString.split(" ");

    for (String s: stations) { //初始化站点
    Station test = new Station(s, lineNo); //要添加的车站
    if (map.contains(test)) { //已经有了
    int index = (map.indexOf(test));
    map.get(index).isInterchangeStation = true;
    map.get(index).line.add(lineNo);
    } else {
    map.add(test);
    }
    }

    for (int i = 0; i < stations.length; i++) { //添加相邻站点
    Station s = new Station(stations[i], lineNo);
    int index = (map.indexOf(s));
    if(stations.length==1) {
    break;
    }
    if (i == 0) {
    Station pres = new Station(stations[i + 1], lineNo);
    int preindex = (map.indexOf(pres));
    map.get(index).linkStations.add(map.get(preindex));
    } else if (i == stations.length - 1) {
    Station nexts = new Station(stations[i - 1], lineNo);
    int nextindex = (map.indexOf(nexts));
    map.get(index).linkStations.add(map.get(nextindex));
    } else {
    Station pres = new Station(stations[i + 1], lineNo);
    int preindex = (map.indexOf(pres));
    Station nexts = new Station(stations[i - 1], lineNo);
    int nextindex = (map.indexOf(nexts));
    map.get(index).linkStations.add(map.get(preindex));
    map.get(index).linkStations.add(map.get(nextindex));
    }
    }
    }
    reader.close();
    }

    2.计划明天继续完成第一个功能,实现地图文本的读入

    3.问题,之前没有见过实现读入的程序,设计,学习,查询询问过程比较艰难,进展缓慢。

  • 相关阅读:
    同源策略一
    执行命令firewallcmd zone=public addport=12345/tcp permanent后提示Error:INVALID_PORT
    ES6、ES7、ES8、ES9、ES10新特性一览 (个人整理,学习笔记)
    同源策略二
    国内加速访问Github的办法,超级简单
    Vue介绍篇
    Vue系列
    wp7中实现 INotifyPropertyChanged 是为了属性变更后的通知的代码笔记
    Sliverlight页面动态布局学习笔记
    windowphone中用WebBrowser加载google地图
  • 原文地址:https://www.cnblogs.com/pekey/p/11414761.html
Copyright © 2011-2022 走看看