public class Obstacle
extends java.lang.Object
Constructor and Description |
---|
Obstacle(java.lang.String name,
java.lang.String description,
double speedFactor,
int noTurns) |
Obstacle(java.lang.String name,
java.lang.String description,
double speedFactor,
int noTurns,
Train target)
Instantiates a new obstacle and applies it to a train
|
Modifier and Type | Method and Description |
---|---|
void |
applyTo(Train t)
Applies the obstacle to a train.
|
java.lang.String |
getDescription() |
java.lang.String |
getName() |
double |
getSpeedFactor()
Returns the speed factor for the obstacle
|
int |
getTurnsElapsed()
Returns the number of turns the obstacle has already been effective for
|
int |
getTurnsLeft()
Returns the number of turns left for this obstacle.
|
boolean |
isActive()
Checks whether the obstacle has been assigned to a Train yet.
|
void |
startTurn()
Increments the internal counter, eventually destroys itself and disassociate
from the Train if the number of turn left is equal to zero.
|
java.lang.String |
toJSON() |
public Obstacle(java.lang.String name, java.lang.String description, double speedFactor, int noTurns)
public Obstacle(java.lang.String name, java.lang.String description, double speedFactor, int noTurns, Train target)
name
- description
- speedFactor
- noTurns
- target
- public java.lang.String getName()
public java.lang.String getDescription()
public void applyTo(Train t)
t
- The train to apply the obstacle to.public boolean isActive()
public int getTurnsLeft()
public int getTurnsElapsed()
public double getSpeedFactor()
public void startTurn()
public java.lang.String toJSON()