package atmsdriver.model;

import atmsdriver.model.Station.DIRECTION;
import java.util.ArrayList;
import java.util.List;

/**
 * Highway represents a freeway that has two directions of traffic. A highway is
 * identified by its highway number.  A highway contains lane detector stations,
 * called Stations, along its length.
 *
 * @author jdalbey
 */
final public class Highway
{
    /** The identifying number for this highway, e.g., 101 */
    public final Integer routeNumber;
    /** The ordered list of stations (lane detector stations) on this highway */
    public final List<Station> stations;
        
    /** Construct a highway 
     * 
     * @param highwayNum integer identifier for this highway
     * @param stations ordered list of stations on this highway
     */
    public Highway(Integer routeNumber, ArrayList<Station> stations)
    {
        this.routeNumber = routeNumber;
        this.stations = stations;
    }
    
    /**
     * 
     */
    public List<DIRECTION> getDirections()
    {
                    // Get available directions for route
            ArrayList<DIRECTION> availDirs = new ArrayList<>();
            for(Station stn : stations)
            {
                if(!availDirs.contains(stn.direction))
                {
                    availDirs.add(stn.direction);
                }
            }
            return availDirs;
    }
    
    @Override
    public String toString()
    {
        return Integer.toString(this.routeNumber);
    }
}
