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

  • 相关阅读:
    secureCRT 6.5 ssh登陆openeuler提示交换秘钥不支持
    ediary电子日记本-力荐
    centos8.4 iso下载地址
    Manjaro Cutefish 安装体验类似macos风格
    脚本启动第一行提示sh/bash找不到
    securecrt双击克隆会话
    开源的window/linux远程连接工具-mRemoeteNG
    securecrt设置日志缓存
    怎么实现通过扫描二维码进行登录
    使用link rel="shortcut icon"为网页标题加图标
  • 原文地址:https://www.cnblogs.com/pekey/p/11414761.html
Copyright © 2011-2022 走看看