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

Revision 237, 1.5 KB checked in by jtorres, 8 years ago (diff)

Added new package atmsdriver.batchbuilder. Includes BatchBuilderGUI, TimeFrame?, TimeFrames?, and TrafficLaneEvent? classes. Added some auxillary methods to Highways.java, Highway.java, and Station.java.

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