public class Train
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected TrackModel |
_tm |
protected double |
acceleration |
protected int |
authority |
protected boolean |
brakeFailure |
protected boolean |
emergencyBrake |
protected double |
emergencyBrakeRate |
protected boolean |
engineFailure |
protected java.text.NumberFormat |
formatter |
protected double |
friction |
protected double |
grade |
protected double |
gravity |
protected TrainModelGUI |
gui |
protected double |
height |
protected int |
leftDoor |
protected double |
length |
protected boolean |
lights |
protected double |
mass |
protected double |
maxAcceleration |
protected int |
maxPassengers |
protected double |
maxPower |
protected double |
maxVelocity |
protected int |
numCars |
protected int |
numCrew |
protected int |
numPassengers |
protected double |
passengerWeight |
protected double |
power |
protected int |
rightDoor |
protected boolean |
serviceBrake |
protected double |
serviceBrakeRate |
protected boolean |
signalFailure |
protected double |
temperature |
protected int |
time |
protected double |
totalForce |
protected double |
totalMass |
protected TrainController |
trainController |
protected double |
velocity |
protected double |
width |
Constructor and Description |
---|
Train(int newTrainId,
int newblockId) |
Train(int newTrainId,
int newblockId,
TrackModel _tm) |
Train(int newTrainId,
int newblockId,
TrackModel _tm,
int test) |
Modifier and Type | Method and Description |
---|---|
boolean |
blockChange()
Method for the train controller to see if the train has changed blocks
|
void |
brakeFailureMode(boolean status)
Turn brake failure on/off
|
void |
engineFailureMode(boolean status)
Turn engine failure on/off
|
boolean |
getAuthority()
Method for the Train Controller to see the authority
|
int |
getBeacon()
Method for the Train Controller to get the beacon information
|
double |
getCurrentTemperature() |
double |
getCurrentVelocity() |
double |
getDisplacement()
Calculates the distances traveled from the last time it was called
|
double |
getEmergencyBrakeRate()
Method for the Train Controller to get the emergency brake rates of the train
|
boolean |
getEmergencyBrakes() |
double |
getGrade()
Helper method to get the grade from the Track Model
|
TrainModelGUI |
getGUI() |
int |
getLeftDoor() |
double |
getLength()
Method for the Track Model to get the length of the train
|
boolean |
getLights() |
int |
getMaxPassengers() |
double |
getMaxPower()
Helper method when setting the power
|
int |
getPassengers() |
double |
getPower()
Method for the Train Controller to get the current power
|
int |
getRightDoor() |
double |
getServiceBrakeRate()
Method for the Train Controller to get the service brake rates of the train
|
boolean |
getServiceBrakes() |
double |
getSuggestedSpeed()
Method for the Train Controller to receive the suggested speed
|
int |
getTime()
Helper method to calculate displacement
|
int |
getTrainId() |
double |
getVelocity() |
void |
setDisplay(java.lang.String message)
Method for the Train Controller to set the display when approaching stops.
|
void |
setEmergencyBrakes(boolean status)
Turn emergency brakes on or off
|
int |
setLeftDoor(int newStatus)
Change the status of the left door
|
boolean |
setLights(boolean status)
Change the status of the lights
|
int |
setPassengers(int passengers)
Method for the Track Model to set the number of passengers in the train
|
void |
setPower(double powerInput,
int test)
Method for the Train Controller to set the power for the train
|
int |
setRightDoor(int newStatus)
Change the status of the right door
|
void |
setServiceBrakes(boolean status)
Turn service brakes on or off
|
void |
setTemperature(double newTemp) |
void |
signalFailureMode(boolean status)
Turn signal failure on/off
|
double |
sine(double gradePercentage)
Calculates the sin of an angle
|
void |
updateSpeed(double forceApplied)
Helper method to update the velocity after given a power.
|
protected TrainController trainController
protected TrackModel _tm
protected int authority
protected double power
protected double maxPower
protected double temperature
protected double velocity
protected double maxVelocity
protected double mass
protected int numCrew
protected int numCars
protected int numPassengers
protected int maxPassengers
protected double passengerWeight
protected double totalMass
protected double friction
protected double grade
protected int time
protected boolean serviceBrake
protected double serviceBrakeRate
protected boolean emergencyBrake
protected double emergencyBrakeRate
protected double gravity
protected double totalForce
protected double acceleration
protected double maxAcceleration
protected boolean lights
protected int leftDoor
protected int rightDoor
protected boolean brakeFailure
protected boolean engineFailure
protected boolean signalFailure
protected double length
protected double height
protected double width
protected TrainModelGUI gui
protected java.text.NumberFormat formatter
public Train(int newTrainId, int newblockId)
public Train(int newTrainId, int newblockId, TrackModel _tm)
public Train(int newTrainId, int newblockId, TrackModel _tm, int test)
public TrainModelGUI getGUI()
public int getTrainId()
public double getPower()
public double getCurrentVelocity()
public double getVelocity()
public int setPassengers(int passengers)
passengers
- The number of passengers that will be boardingpublic int getPassengers()
public void setDisplay(java.lang.String message)
message
- The message to be displayedpublic int getMaxPassengers()
public double getLength()
public double getMaxPower()
public boolean blockChange()
public boolean getAuthority()
public double getSuggestedSpeed()
public int getBeacon()
public double getGrade()
public void setPower(double powerInput, int test)
powerInput
- the power to be setpublic double sine(double gradePercentage)
gradePercentage
- the percent of grade of the current blockpublic boolean getServiceBrakes()
public void setServiceBrakes(boolean status)
status
- the new status to be setpublic boolean getEmergencyBrakes()
public void setEmergencyBrakes(boolean status)
status
- the new status to be setpublic double getEmergencyBrakeRate()
public double getServiceBrakeRate()
public void updateSpeed(double forceApplied)
forceApplied
- the force after a new power is set.public double getCurrentTemperature()
public void setTemperature(double newTemp)
newTemp
- desired new inside temperaturepublic boolean getLights()
public boolean setLights(boolean status)
status
- The new status of the lightspublic int getLeftDoor()
public int setLeftDoor(int newStatus)
newStatus
- The new status that the left door should be set topublic int getRightDoor()
public int setRightDoor(int newStatus)
newStatus
- The new status that the right door should be set topublic int getTime()
public void signalFailureMode(boolean status)
status
- new status of the signal failure modepublic void brakeFailureMode(boolean status)
status
- new status of the brake failure modepublic void engineFailureMode(boolean status)
status
- new status of the engine failure modepublic double getDisplacement()