2020-02-15 14:17:23 +00:00
|
|
|
package edu.kit.informatik;
|
|
|
|
|
2020-02-15 15:38:54 +00:00
|
|
|
/**
|
|
|
|
* Train set.
|
|
|
|
*
|
|
|
|
* @author Arne Keller
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
2020-02-15 14:17:23 +00:00
|
|
|
public class TrainSet extends RollingStock {
|
2020-02-15 15:38:54 +00:00
|
|
|
private static final String[] TRAIN_SET_TEXT = new String[] {
|
|
|
|
" ++ ",
|
|
|
|
" || ",
|
|
|
|
"_________||_________",
|
|
|
|
"| ___ ___ ___ ___ |",
|
|
|
|
"| |_| |_| |_| |_| |",
|
|
|
|
"|__________________|",
|
|
|
|
"|__________________|",
|
|
|
|
" (O) (O) "
|
|
|
|
};
|
|
|
|
|
2020-02-15 14:17:23 +00:00
|
|
|
private String series;
|
|
|
|
private String name;
|
|
|
|
|
2020-02-15 15:38:54 +00:00
|
|
|
/**
|
|
|
|
* Construct a new train set.
|
|
|
|
* @param series series/class of train set
|
|
|
|
* @param name name of train set
|
|
|
|
* @param length length of train set
|
|
|
|
* @param couplingFront whether the train set should have a front coupling
|
|
|
|
* @param couplingBack whether the train set should have a back coupling
|
|
|
|
*/
|
|
|
|
public TrainSet(final String series, final String name, final int length,
|
|
|
|
final boolean couplingFront, final boolean couplingBack) {
|
2020-02-15 14:17:23 +00:00
|
|
|
this.name = name;
|
|
|
|
this.series = series;
|
|
|
|
super.length = length;
|
|
|
|
super.couplingFront = couplingFront;
|
|
|
|
super.couplingBack = couplingBack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getIdentifier() {
|
|
|
|
return String.format("%s-%s", series, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return String.format("%s %s %d %b %b", series, name, length, couplingFront, couplingBack);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canCoupleFrontTo(RollingStock rollingStock) {
|
|
|
|
return hasCouplingFront() && rollingStock.hasCouplingBack() && rollingStock.canCoupleToTrainSetSeries(series);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canCoupleToTrainSetSeries(String series) {
|
|
|
|
return this.series.equals(series);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String[] textRepresentation() {
|
|
|
|
return TRAIN_SET_TEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String description() {
|
|
|
|
return "train-set";
|
|
|
|
}
|
|
|
|
}
|