net.kolls.railworld
Interface Car

All Superinterfaces:
SaveLoad
All Known Implementing Classes:
AbstractCar, Autorack, Boxcar, Caboose, CachedCar, Coveredhopper, Engine, Flatcar, Intermodal, Openhopper, Passenger, Stockcar, Tankcar

public interface Car
extends SaveLoad

Car represents a basic railcar, which may either be a loadable (cargo type) or not. The Car class contains a registry for tracking a Car's location, as well as information on its appearance and characteristics.

Author:
Steve Kollmansberger

Field Summary
static Distance CAR_WIDTH
          The width of a car.
static Distance DIST_BETWEEN_CARS
          The distance between cars (shown as empty space).
 
Method Summary
 boolean canUserCreate()
          Indicates if this car should appear in any user creation selection window.
 java.awt.Color color()
          Return the Car's color.
 boolean isEngine()
          Indicates if this car provides power.
 boolean isLoadable()
          Determine if the current Car can be loaded and unloaded; that is, does it carry cargo.
 Distance length()
          Returns the length of this Car.
 void load()
          Loads the current Car.
 boolean loaded()
          Indicates if the Car is currently loaded.
 java.awt.Color midColor()
          Indicates what the middle line (loaded) color should be.
 java.util.Set<RailSegment> segs()
          For the current Car, returns the segments that the Car occupies, if any.
 java.lang.String show()
          Gives a human-readable word for the Car.
 void unload()
          Unloads the current Car.
 int weight()
          Returns the weight of this Car (taking load/unload into account, if necessary) in US Tons.
 
Methods inherited from interface net.kolls.railworld.io.SaveLoad
load, newInstance, save, toString
 

Field Detail

DIST_BETWEEN_CARS

static final Distance DIST_BETWEEN_CARS
The distance between cars (shown as empty space).


CAR_WIDTH

static final Distance CAR_WIDTH
The width of a car.

Method Detail

loaded

boolean loaded()
Indicates if the Car is currently loaded.

Returns:
true if the car is loadable and is currently loaded.

load

void load()
Loads the current Car. Do not call on a Car you have specified as not loadable.


unload

void unload()
Unloads the current Car. Do not call on a Car you have specified as not loadable.


isLoadable

boolean isLoadable()
Determine if the current Car can be loaded and unloaded; that is, does it carry cargo.

Returns:
true if the Car may be loaded and unloaded. Defaults to true.

segs

java.util.Set<RailSegment> segs()
For the current Car, returns the segments that the Car occupies, if any. This should be considered read-only.

Returns:
Set of RailSegments.

color

java.awt.Color color()
Return the Car's color. The following color assignments exist: black: open hopper car blue: tank car cyan: intermodal dark gray: engine gray: green: covered hopper light gray: passenger magenta: auto rack orange: centerbeam flat car pink: boxcar red: caboose white: yellow: stock car

Returns:
The Color of the current Car.

midColor

java.awt.Color midColor()
Indicates what the middle line (loaded) color should be. Used by TrainPainter.

Returns:
The Color of the middle line in the car

show

java.lang.String show()
Gives a human-readable word for the Car. Should indicate only the type of the Car, not whether it is loaded or unloaded.

Returns:
String indicating type of Car.

weight

int weight()
Returns the weight of this Car (taking load/unload into account, if necessary) in US Tons. 1 US Ton = 2000 US Pounds

Returns:
int representing weight in tons.

length

Distance length()
Returns the length of this Car.

Returns:
Distance indicating the length of the Car.

canUserCreate

boolean canUserCreate()
Indicates if this car should appear in any user creation selection window.

Returns:
true if the car is user creatable

isEngine

boolean isEngine()
Indicates if this car provides power.

Returns:
true if the car provides power (is a working engine)