Initial Commit
This commit is contained in:
31
Source Code/Assignment 4/src/TankTrain.java
Normal file
31
Source Code/Assignment 4/src/TankTrain.java
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* TankTrain class
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class TankTrain extends TrainCar {
|
||||
double litres;
|
||||
boolean hazardous;
|
||||
|
||||
/**
|
||||
* The constructor for the tank train
|
||||
* @param code The unique code for the tank train
|
||||
* @param inspectionYr The year the train was last inspected
|
||||
* @param litres The litres the train is carrying
|
||||
* @param hazardous If the train is carrying hazardous materials
|
||||
*/
|
||||
TankTrain(String code, int inspectionYr, double litres, boolean hazardous) {
|
||||
super(code, inspectionYr);
|
||||
this.litres = litres;
|
||||
this.hazardous = hazardous;
|
||||
}
|
||||
|
||||
/**
|
||||
* The income calculator specific to tank train
|
||||
* @return The income of that train
|
||||
*/
|
||||
@Override
|
||||
double calculateIncome() {
|
||||
return (hazardous) ? litres*17 : litres*9.5;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user