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.问题,之前没有见过实现读入的程序,设计,学习,查询询问过程比较艰难,进展缓慢。

  • 相关阅读:
    java.lang.IllegalArgumentException: node to traverse cannot be null!
    c3p0连接池的使用
    eclipse插件
    eclipse字体颜色设置
    oracle增删改查
    resultMap / resultType
    oracle 序列 ,check约束
    JSP:一种服务器端动态页面技术的组件规范。
    js
    字体
  • 原文地址:https://www.cnblogs.com/pekey/p/11414761.html
Copyright © 2011-2022 走看看