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"; } }