jfreerails.world.track
Class TrackRuleImpl

java.lang.Object
  extended by jfreerails.world.track.TrackRuleImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TrackRule>, FreerailsSerializable, TrackRule

public final class TrackRuleImpl
extends java.lang.Object
implements TrackRule

This class encapsulates the rules that apply to a type of track node. They concern: the legal routes trains can travel across the node, whether the node's track can be doubled, on which terrain types it can be built, and the maximum number of consecutive nodes of this type (used for bridges and tunnels).

Author:
Luke Lindsay 09 October 2001
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface jfreerails.world.track.TrackRule
TrackRule.TrackCategories
 
Field Summary
private  LegalTrackConfigurations legalConfigurations
           
private  LegalTrackPlacement legalTrackPlacement
           
private  TrackRuleProperties properties
           
private static long serialVersionUID
           
 
Constructor Summary
TrackRuleImpl(TrackRuleProperties p, LegalTrackConfigurations lc, LegalTrackPlacement ltp)
           
 
Method Summary
 boolean canBuildOnThisTerrainType(TerrainType.Category TerrainType)
           
 int compareTo(TrackRule otherRule)
          If the specified object is a track rule, comparison is by category then price.
 boolean equals(java.lang.Object o)
           
 TrackRule.TrackCategories getCategory()
           
 Money getFixedCost()
           
 LegalTrackConfigurations getLegalConfigurations()
           
 java.util.Iterator<TrackConfiguration> getLegalConfigurationsIterator()
           
 Step[] getLegalRoutes(Step directionComingFrom)
           
 LegalTrackPlacement getLegalTrackPlacement()
           
 Money getMaintenanceCost()
           
 int getMaximumConsecutivePieces()
           
 Money getPrice()
           
 TrackRuleProperties getProperties()
           
 int getStationRadius()
           
 java.lang.String getTypeName()
           
 int hashCode()
           
 boolean isDouble()
           
 boolean isStation()
           
 boolean testTrackPieceLegality(int trackTemplateToTest)
           
 java.lang.String toString()
           
 boolean trackPieceIsLegal(TrackConfiguration config)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

legalConfigurations

private final LegalTrackConfigurations legalConfigurations

legalTrackPlacement

private final LegalTrackPlacement legalTrackPlacement

properties

private final TrackRuleProperties properties
Constructor Detail

TrackRuleImpl

public TrackRuleImpl(TrackRuleProperties p,
                     LegalTrackConfigurations lc,
                     LegalTrackPlacement ltp)
Method Detail

canBuildOnThisTerrainType

public boolean canBuildOnThisTerrainType(TerrainType.Category TerrainType)
Specified by:
canBuildOnThisTerrainType in interface TrackRule

compareTo

public int compareTo(TrackRule otherRule)
If the specified object is a track rule, comparison is by category then price.

Specified by:
compareTo in interface java.lang.Comparable<TrackRule>

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getCategory

public TrackRule.TrackCategories getCategory()
Specified by:
getCategory in interface TrackRule

getLegalConfigurations

public LegalTrackConfigurations getLegalConfigurations()

getLegalConfigurationsIterator

public java.util.Iterator<TrackConfiguration> getLegalConfigurationsIterator()
Specified by:
getLegalConfigurationsIterator in interface TrackRule

getLegalRoutes

public Step[] getLegalRoutes(Step directionComingFrom)
Specified by:
getLegalRoutes in interface TrackRule

getLegalTrackPlacement

public LegalTrackPlacement getLegalTrackPlacement()

getMaintenanceCost

public Money getMaintenanceCost()
Specified by:
getMaintenanceCost in interface TrackRule

getMaximumConsecutivePieces

public int getMaximumConsecutivePieces()
Specified by:
getMaximumConsecutivePieces in interface TrackRule

getPrice

public Money getPrice()
Specified by:
getPrice in interface TrackRule

getProperties

public TrackRuleProperties getProperties()

getStationRadius

public int getStationRadius()
Specified by:
getStationRadius in interface TrackRule

getTypeName

public java.lang.String getTypeName()
Specified by:
getTypeName in interface TrackRule

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isStation

public boolean isStation()
Specified by:
isStation in interface TrackRule

testTrackPieceLegality

public boolean testTrackPieceLegality(int trackTemplateToTest)
Specified by:
testTrackPieceLegality in interface TrackRule

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

trackPieceIsLegal

public boolean trackPieceIsLegal(TrackConfiguration config)
Specified by:
trackPieceIsLegal in interface TrackRule

isDouble

public boolean isDouble()
Specified by:
isDouble in interface TrackRule

getFixedCost

public Money getFixedCost()
Specified by:
getFixedCost in interface TrackRule