|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.Train
public class Train
Represents a train (sequence of cars), including its position and controller.
| Field Summary | |
|---|---|
boolean |
followMe
Should the display track this train. |
boolean |
followMeOnce
The display should jump to this train's location, but not continue to follow it. |
static int |
MAX_SPEED_MPH
Maximum speed (mph) for the train. |
static int |
MAX_THROTTLE
The maximum throttle setting for the train (not related to maximum speed) |
CLoc |
pos
Trains position. |
boolean |
reverse
Does this train request to be reversed? Controller must ensure train is stopped first. |
boolean |
split
Does this train request to be split? Controller must ensure train is stopped and car other than the first selected. |
| Constructor Summary | |
|---|---|
Train(Car[] cars)
Create a train from a given array of cars. |
|
| Method Summary | |
|---|---|
void |
adjust()
Calculates the trains acceleration and velocity based on the controls. |
Car[] |
array()
|
double |
feetToSlow(double vel)
Calculate, if the throttle were set to 0 and the brake applied, how many feet it would take for the train to slow to the requested velocity. |
boolean |
getBrake()
|
TrainControl |
getController()
Returns controller for this train. |
int |
getThrottle()
|
boolean |
hasEngine()
|
Distance |
length()
The length is the length of all cars, with the distance between cars also added in. |
void |
setBrake(boolean b)
Set or release the brake. |
void |
setController(TrainControl controller)
Updates a train's controller. |
void |
setThrottle(int t)
Update the throttle. |
void |
setVel(double v)
Directly and immediately alter the train's velocity. |
double |
vel()
|
int |
weight()
The weight of the train is the sum of the weights of the cars. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_THROTTLE
public CLoc pos
public boolean followMe
public boolean reverse
public boolean split
public boolean followMeOnce
public static final int MAX_SPEED_MPH
| Constructor Detail |
|---|
public Train(Car[] cars)
MixController is assigned by default.
cars - Array of Cars.| Method Detail |
|---|
public boolean hasEngine()
true if the train has one or more engines.public int weight()
public TrainControl getController()
TrainControl.public void setController(TrainControl controller)
controller - The new controller to use.public Distance length()
Distance measuring the length of the train.public double vel()
public void setVel(double v)
v - New velocity, MPH.public int getThrottle()
public boolean getBrake()
true if the brake is active.public void setThrottle(int t)
MAX_THROTTLE
t - Throttle settingpublic void setBrake(boolean b)
b - public Car[] array()
Cars that compose this train.public void adjust()
GameLoop.CLOCK_WAIT.
public double feetToSlow(double vel)
vel - Target velocity, in MPH. May be 0 for stopped.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||