Warning: Can't use blame annotator:
svn blame failed on trunk/src/atmsdriver/model/Highway.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/src/atmsdriver/model/Highway.java @ 353

Revision 353, 1.7 KB checked in by jdalbey, 7 years ago (diff)

StationComparator?.java added to json output can be ordered by route then postmile.

RevLine 
1package atmsdriver.model;
2
3import atmsdriver.model.Station.DIRECTION;
4import java.util.ArrayList;
5import java.util.HashSet;
6import java.util.List;
7import java.util.Set;
8import java.util.SortedSet;
9import java.util.TreeSet;
10
11/**
12 * Highway represents a freeway that has two directions of traffic. A highway is
13 * identified by its highway number.  A highway contains lane detector stations,
14 * called Stations, along its length.
15 *
16 * @author jdalbey
17 */
18final public class Highway implements Comparable<Highway>
19{
20    /** The identifying number for this highway, e.g., 101 */
21    public final Integer routeNumber;
22    /** The ordered list of stations (lane detector stations) on this highway */
23    public final List<Station> stations;
24    /** The directions for this highway, either N/S or E/W */
25    public final Set<DIRECTION> availDirs = new TreeSet<DIRECTION>();
26   
27    /** Construct a highway
28     *
29     * @param highwayNum integer identifier for this highway
30     * @param stations ordered list of stations on this highway
31     */
32    public Highway(Integer routeNumber, ArrayList<Station> stations)
33    {
34        this.routeNumber = routeNumber;
35        this.stations = stations;
36        // Get available directions for route
37        if (stations != null)
38        {
39            for(Station stn : stations)
40            {
41                availDirs.add(stn.direction);
42            }
43        }
44    }
45   
46    @Override
47    public String toString()
48    {
49        return Integer.toString(this.routeNumber);
50    }
51
52    @Override
53    public int compareTo(Highway other)
54    {
55        int otherRoute = ((Highway) other).routeNumber; 
56        //ascending order
57        return this.routeNumber - otherRoute;       
58    }
59}
Note: See TracBrowser for help on using the repository browser.