kit-programmieren-ws1920-fi.../src/edu/kit/informatik/Engine.java
2020-02-15 16:38:54 +01:00

33 lines
792 B
Java

package edu.kit.informatik;
public abstract class Engine extends RollingStock {
/**
* Series/class of this engine.
*/
protected String series;
/**
* Name of this engine.
*/
protected String name;
public String getName() {
return name;
}
@Override
public String getIdentifier() {
return String.format("%s-%s", series, getName());
}
@Override
public boolean canCoupleFrontTo(RollingStock rollingStock) {
// train-sets can ONLY connect to other matching train-sets, not to engines.
return hasCouplingFront() && rollingStock.hasCouplingBack() && !(rollingStock instanceof TrainSet);
}
@Override
public boolean canCoupleToTrainSetSeries(String series) {
return false;
}
}