Changeset 212 in tmcsimulator for trunk/src/atmsdriver/model/Highways.java


Ignore:
Timestamp:
11/02/2017 01:42:45 PM (9 years ago)
Author:
jtorres
Message:

branches/FEPSimulator/tests/HighwaysParserTest.cpp: Unit test for HighwaysParser?.cpp. HighwaysTest?.java: now passing toXML(), added test for toCondensedFormat() method. LoadHighwaysTest?.java: passing. LoadSadDotsTest?.java: conformed to changes, not passing. Highway.java/Highways.java: converted class attributes to List instead of ArrayList?. Highways.java: corrected toCondensedFormat() method comments and added comments throughout file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/model/Highways.java

    r203 r212  
    1212import java.util.Collections; 
    1313import java.util.HashMap; 
     14import java.util.List; 
    1415import java.util.Map; 
    1516import java.util.Scanner; 
     
    5253    final private int FEPPortNum; 
    5354     
    54     final private ArrayList<FEPLine> lines; 
    55     final public ArrayList<Highway> highways; 
     55    final private List<FEPLine> lines; 
     56    final public List<Highway> highways; 
    5657 
    5758    public Highways(String highwaysMapFileName, String FEPHostName, int FEPPortNum) 
     
    227228        String line = sc.nextLine(); 
    228229        Scanner scline = new Scanner(line); 
    229         // Get the attribute of this FEP Line 
     230        // Get the attributes of this FEP Line 
    230231        int lineNum = scline.nextInt(); 
    231232        int count = scline.nextInt(); 
    232233        int numStations = scline.nextInt(); 
     234         
     235        // initialze stations array 
    233236        ArrayList<Station> stations = new ArrayList<>(); 
    234237        // Read all the stations for thie FEP Line 
     
    251254        String line = sc.nextLine(); 
    252255        Scanner scline = new Scanner(line); 
     256         
    253257        int ldsID = scline.nextInt(); 
    254258        int drop = scline.nextInt(); 
     
    371375     * Example toCondensedFormat(MetaDataOnly = false) output: 
    372376     *  
    373      * 43                   // "number of lines" 
    374      * 32 0 13              // "line id" "count num" "number of stations" 
    375      * 1210831 1 5 S 0.9 8  // "station id" "drop num" "route num"... 
    376      *                      //      ..."direction" "postmile" "number of loops" 
    377      * 1210832  0.0 0       // "loop id" "occ" "vol" 
    378      * 1210833  0.0 0       // .. 
    379      * 1210834  0.0 0       // .. 
    380      * 1210835  0.0 0       // .. 
    381      * 1210836  0.0 0       // .. 
    382      * 1210837  0.0 0       // .. 
    383      * 1210838  0.0 0       // .. 
    384      * 1210839  0.0 0      // .. 
     377     * 43                       // "number of lines" 
     378     * 32 0 13                  // "line id" "count num" "number of stations" 
     379     * 1210831 1 5 S 0.9 8      // "station id" "drop num" "route num"... 
     380     *                          //      ..."direction" "postmile" "number of loops" 
     381     * 1210832  0.0 0  ML_1     // "loop id" "occ" "vol" 
     382     * 1210833  0.0 0  ML_2     // .. 
     383     * 1210834  0.0 0  ML_3     // .. 
     384     * 1210835  0.0 0  ML_4     // .. 
     385     * 1210836  0.0 0  PASSAGE  // .. 
     386     * 1210837  0.0 0  DEMAND   // .. 
     387     * 1210838  0.0 0  QUEUE    // .. 
     388     * 1210839  0.0 0  RAMP_OFF // .. 
    385389     * ... 
    386390     *  
     
    404408    public String toCondensedFormat(boolean MetaDataOnly) 
    405409    { 
     410        // first line: number of FEPLines 
    406411        StringBuilder build = new StringBuilder(); 
    407412        build.append(lines.size()); 
    408413        build.append("\n"); 
     414        // append each fep line to the string 
    409415        for(FEPLine line : lines) 
    410416        { 
    411417            build.append(line.toCondensedFormat(MetaDataOnly)); 
    412418        } 
     419        // return the full condensed format string 
    413420        return build.toString(); 
    414421    } 
     
    458465     *  
    459466     * @param routeNum 
    460      * @return Highway with specified route number 
     467     * @return Highway with specified route number, or null if no highway with 
     468     *          the specified route num 
    461469     */ 
    462470    public Highway getHighwayByRouteNumber(Integer routeNum) 
    463471    { 
    464472        Highway returnHwy = null; 
     473        // search through highways and check routeNums 
    465474        for (Highway hwy : highways) 
    466475        { 
Note: See TracChangeset for help on using the changeset viewer.