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


Ignore:
Timestamp:
10/30/2017 01:35:05 PM (9 years ago)
Author:
jdalbey
Message:

Highways.java: Added toString() method. Station.java: Added getColorByDirection method. Added testToString to HighwaysTest?.

File:
1 edited

Legend:

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

    r190 r191  
    198198        { 
    199199            Scanner sc = new Scanner(new File(highwaysMapFileName)); 
     200            // first line of file contains number of FEP Lines 
    200201            String firstLine = sc.nextLine(); 
    201  
    202202            Scanner linesc = new Scanner(firstLine); 
    203203            int numLines = linesc.nextInt(); 
    204204            linesc.close(); 
    205  
     205            // FOR each FEP Line 
    206206            for (int i = 0; i < numLines; i++) 
    207207            { 
     
    227227        String line = sc.nextLine(); 
    228228        Scanner scline = new Scanner(line); 
    229  
     229        // Get the attribute of this FEP Line 
    230230        int lineNum = scline.nextInt(); 
    231231        int count = scline.nextInt(); 
    232232        int numStations = scline.nextInt(); 
    233233        ArrayList<Station> stations = new ArrayList<>(); 
     234        // Read all the stations for thie FEP Line 
    234235        for (int i = 0; i < numStations; i++) 
    235236        { 
     
    473474    } 
    474475 
     476    /** Return a string representation of the Highways */ 
     477    public String toString() 
     478    { 
     479        StringBuilder result = new StringBuilder(); 
     480        for (Highway hwy: highways) 
     481        { 
     482            result.append(""+String.format("%3s ",hwy.routeNumber)); 
     483            for (Station stat: hwy.stations) 
     484            { 
     485                result.append(stat.getColorByDirection(stat.direction)); 
     486            } 
     487            result.append("\n"); 
     488        } 
     489        return result.toString(); 
     490    } 
    475491    /** 
    476492     * XML tags used in writeToXML() 
Note: See TracChangeset for help on using the changeset viewer.