com.TeamHEC.LocomotionCommotion.Train
Class Train

java.lang.Object
  extended by com.TeamHEC.LocomotionCommotion.Train.Train
Direct Known Subclasses:
CoalTrain, ElectricTrain, NuclearTrain, OilTrain

public abstract class Train
extends java.lang.Object

Author:
Matthew Taylor

Field Summary
 int fuelPerTurn
           
 Route route
           
 
Constructor Summary
Train(java.lang.String name, Fuel fuelType, int baseSpeed, int speedMod, int value, boolean inStation, Route route, Player owner)
          The superclass of Train types, Creates a Train for player.
 
Method Summary
 void addUpgrade(TrainUpgrade upgrade)
          Adds an upgrade to the current train:
 void backupSpeedMod()
          Backs up speedMod
 void decreaseFuelPerTurn(int by)
          decrease the fuel per turn of a train
 void decreaseSpeedMod(int by)
          decrease a train's speed modifier
 Game_Map_Train getActor()
           
 int getFuelLengthCost(float length)
           
 int getFuelPerTurn()
          Get the fuel per turn of a train
 int getFuelRouteCost()
           
 java.lang.String getFuelType()
           
 java.lang.String getName()
          Get the train's name
 Player getOwner()
          Get the owner of a train
 Route getRoute()
          Get the route of a train
 int getSpeed()
           
 int getSpeedMod()
          Get the speed modifier of a train
 int getValue()
          Get the value of the train
 void increaseSpeedMod(int by)
          Increase a train's speed modifier
 boolean isInStation()
          Gets if a train is in a station
 void moveTrain()
          Moves the train through it's route
 void removeUpgrade(TrainUpgrade upgrade)
          Removes an upgrade from a train
 void restoreSpeedMod()
          Restores speedMod from speedModBackup
 void setFuelPerTurn(int fuelPerTurn)
          set the fuel per turn of a train
 void setInStation(boolean inStation)
          sets if a train is in a station
 void setSpeedMod(int speedMod)
          Set the speed modifier of a train
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fuelPerTurn

public int fuelPerTurn

route

public final Route route
Constructor Detail

Train

public Train(java.lang.String name,
             Fuel fuelType,
             int baseSpeed,
             int speedMod,
             int value,
             boolean inStation,
             Route route,
             Player owner)
The superclass of Train types, Creates a Train for player.

Parameters:
fuelType - Type of fuel the train consumes
speedMod - Any speed modifications made to the train
value - The price of the train
inStation - whether the train is currently in a station
route - The route the train is currently using
owner - The owner of the train
Method Detail

getActor

public Game_Map_Train getActor()
Returns:
The Actor (UI Element) for the train

getName

public java.lang.String getName()
Get the train's name

Returns:
String name

getValue

public int getValue()
Get the value of the train

Returns:
Int value

getOwner

public Player getOwner()
Get the owner of a train

Returns:
Player

getSpeed

public int getSpeed()
Returns:
Speed of the train with upgrades:

getSpeedMod

public int getSpeedMod()
Get the speed modifier of a train

Returns:
Int speed modifier

getFuelPerTurn

public int getFuelPerTurn()
Get the fuel per turn of a train

Returns:
Int fuel per turn

getFuelRouteCost

public int getFuelRouteCost()
Returns:
The amount of fuel for the remaining route:

getFuelLengthCost

public int getFuelLengthCost(float length)
Parameters:
length - the length of distance you want to travel
Returns:
The amount of fuel needed to travel that distance

getFuelType

public java.lang.String getFuelType()
Returns:
a string detailing the fuel type used by a train:

getRoute

public Route getRoute()
Get the route of a train

Returns:
Route

setSpeedMod

public void setSpeedMod(int speedMod)
Set the speed modifier of a train

Parameters:
speedMod -

setFuelPerTurn

public void setFuelPerTurn(int fuelPerTurn)
set the fuel per turn of a train

Parameters:
fuelPerTurn -

increaseSpeedMod

public void increaseSpeedMod(int by)
Increase a train's speed modifier

Parameters:
by -

decreaseSpeedMod

public void decreaseSpeedMod(int by)
decrease a train's speed modifier

Parameters:
by -

decreaseFuelPerTurn

public void decreaseFuelPerTurn(int by)
decrease the fuel per turn of a train

Parameters:
by -

setInStation

public void setInStation(boolean inStation)
sets if a train is in a station

Parameters:
inStation - true if a the train is currently in a station

isInStation

public boolean isInStation()
Gets if a train is in a station

Returns:
Boolean in station

moveTrain

public void moveTrain()
Moves the train through it's route


backupSpeedMod

public void backupSpeedMod()
Backs up speedMod


restoreSpeedMod

public void restoreSpeedMod()
Restores speedMod from speedModBackup


addUpgrade

public void addUpgrade(TrainUpgrade upgrade)
Adds an upgrade to the current train:

Parameters:
upgrade - The upgrade to be added

removeUpgrade

public void removeUpgrade(TrainUpgrade upgrade)
Removes an upgrade from a train

Parameters:
upgrade - the upgrade to be removed