Class CarManager

    • Method Detail

      • newRS

        public Car newRS​(java.lang.String road,
                         java.lang.String number)
        Finds an existing Car or creates a new Car if needed requires car's road and number
        Specified by:
        newRS in class RollingStockManager<Car>
        Parameters:
        road - car road
        number - car number
        Returns:
        new car or existing Car
      • getByKernelList

        public java.util.List<CargetByKernelList()
        Sort by car kernel names
        Returns:
        list of cars ordered by car kernel
      • getByLoadList

        public java.util.List<CargetByLoadList()
        Sort by car loads
        Returns:
        list of cars ordered by car loads
      • getByRweList

        public java.util.List<CargetByRweList()
        Sort by car return when empty location and track
        Returns:
        list of cars ordered by car return when empty
      • getByWaitList

        public java.util.List<CargetByWaitList()
        Sort by car wait count
        Returns:
        list of cars ordered by wait count
      • getAvailableTrainList

        public java.util.List<CargetAvailableTrainList​(Train train)
        Return a list available cars (no assigned train or car already assigned to this train) on a route, cars are ordered least recently moved to most recently moved.
        Parameters:
        train - The Train to use.
        Returns:
        List of cars with no assigned train on a route
      • getByTrainDestinationList

        public java.util.List<CargetByTrainDestinationList​(Train train)
        Provides a very sorted list of cars assigned to the train. Note that this isn't the final sort as the cars must be sorted by each location the train visits.

        The sort priority is as follows:

        1. Caboose or car with FRED to the end of the list, unless passenger.
        2. Passenger cars have blocking numbers which places them relative to each other. Passenger cars with positive blocking numbers to the end of the list, but before cabooses or car with FRED. Passenger cars with negative blocking numbers are placed at the front of the train.
        3. Car's destination (alphabetical by location and track name or by track blocking order)
        4. Car is hazardous (hazardous placed after a non-hazardous car)
        5. Car's current location (alphabetical by location and track name)
        6. Car's final destination (alphabetical by location and track name)

        Cars in a kernel are placed together by their kernel blocking numbers, except if they are type passenger. The kernel's position in the list is based on the lead car in the kernel.

        If the train is to be blocked by track blocking order, all of the tracks at that location need a blocking number greater than 0.

        Parameters:
        train - The selected Train.
        Returns:
        Ordered list of cars assigned to the train
      • getCabooseRoadNames

        public java.util.List<java.lang.String> getCabooseRoadNames()
        Get a list of car road names where the car was flagged as a caboose.
        Returns:
        List of caboose road names.
      • getFredRoadNames

        public java.util.List<java.lang.String> getFredRoadNames()
        Get a list of car road names where the car was flagged with FRED
        Returns:
        List of road names of cars with FREDs
      • replaceLoad

        public void replaceLoad​(java.lang.String type,
                                java.lang.String oldLoadName,
                                java.lang.String newLoadName)
        Replace car loads
        Parameters:
        type - type of car
        oldLoadName - old load name
        newLoadName - new load name
      • calculateCarWeight

        public static java.lang.String calculateCarWeight​(java.lang.String carLength)
                                                   throws java.lang.NumberFormatException
        Determines a car's weight in ounces based on car's scale length
        Parameters:
        carLength - Car's scale length
        Returns:
        car's weight in ounces
        Throws:
        java.lang.NumberFormatException - if length isn't a number
      • isThereDivisions

        public boolean isThereDivisions()
        Used to determine if any car has been assigned a division
        Returns:
        true if any car has been assigned a division, otherwise false
      • load

        public void load​(org.jdom2.Element root)
      • store

        public void store​(org.jdom2.Element root)
        Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-cars.dtd.
        Parameters:
        root - The common Element for operations-cars.dtd.
      • setDirtyAndFirePropertyChange

        protected void setDirtyAndFirePropertyChange​(java.lang.String p,
                                                     java.lang.Object old,
                                                     java.lang.Object n)