mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final1.git
synced 2024-11-24 17:34:58 +00:00
56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
|
package edu.kit.informatik;
|
||
|
|
||
|
public class TrainSet extends RollingStock {
|
||
|
private String series;
|
||
|
private String name;
|
||
|
|
||
|
public TrainSet(final String series, final String name, final int length, final boolean couplingFront, final boolean couplingBack) {
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
private static final String[] TRAIN_SET_TEXT = new String[] {
|
||
|
" ++ ",
|
||
|
" || ",
|
||
|
"_________||_________",
|
||
|
"| ___ ___ ___ ___ |",
|
||
|
"| |_| |_| |_| |_| |",
|
||
|
"|__________________|",
|
||
|
"|__________________|",
|
||
|
" (O) (O) "
|
||
|
};
|
||
|
|
||
|
@Override
|
||
|
public String[] textRepresentation() {
|
||
|
return TRAIN_SET_TEXT;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String description() {
|
||
|
return "train-set";
|
||
|
}
|
||
|
}
|