From c0f22b26979136ccd2b58571874093e28eb6787d Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 5 Mar 2020 21:54:18 +0100 Subject: [PATCH] Checkstyle --- src/edu/kit/informatik/model/Train.java | 86 ++++++++++++------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/edu/kit/informatik/model/Train.java b/src/edu/kit/informatik/model/Train.java index 3cf0e47..13081be 100644 --- a/src/edu/kit/informatik/model/Train.java +++ b/src/edu/kit/informatik/model/Train.java @@ -79,49 +79,6 @@ public final class Train { } } - @Override - public String toString() { - final StringBuilder stringBuilder = new StringBuilder(Integer.toString(getIdentifier())); - for (final RollingStock rollingStock : rollingStocks) { - stringBuilder.append(' '); - stringBuilder.append(rollingStock.getIdentifier()); - } - return stringBuilder.toString(); - } - - /** - * Get the ASCII art of this train. - * - * @return rows of ASCII art - */ - public List show() { - final List lines = new ArrayList<>(); - for (final RollingStock rollingStock : rollingStocks) { - for (final StringBuilder line : lines) { - line.append(' '); - } - final String[] text = rollingStock.textRepresentation(); - final int currentLength = lines.stream().mapToInt(StringBuilder::length).max().orElse(0); - while (lines.size() < text.length) { - final StringBuilder line = new StringBuilder(); - for (int i = 0; i < currentLength; i++) { - line.append(' '); - } - lines.add(0, line); - } - for (int i = 0; i < text.length; i++) { - lines.get(lines.size() - 1 - i).append(text[text.length - 1 - i]); - } - final int finalLength = lines.stream().mapToInt(StringBuilder::length).max().getAsInt(); - for (final StringBuilder line : lines) { - while (line.length() < finalLength) { - line.append(' '); - } - } - } - return lines.stream().map(StringBuilder::toString).collect(Collectors.toList()); - } - /** * Check whether this train is on a particular rail. Note that at least one rolling stock has to be on the rail, * just touching the rail is not enough. @@ -367,4 +324,47 @@ public final class Train { public long getLength() { return rollingStocks.stream().mapToLong(RollingStock::getLength).sum(); } + + /** + * Get the ASCII art of this train. + * + * @return rows of ASCII art + */ + public List show() { + final List lines = new ArrayList<>(); + for (final RollingStock rollingStock : rollingStocks) { + for (final StringBuilder line : lines) { + line.append(ROLLING_STOCK_SEPARATOR); + } + final String[] text = rollingStock.textRepresentation(); + final int currentLength = lines.stream().mapToInt(StringBuilder::length).max().orElse(0); + while (lines.size() < text.length) { + final StringBuilder line = new StringBuilder(); + for (int i = 0; i < currentLength; i++) { + line.append(ROLLING_STOCK_SEPARATOR); + } + lines.add(0, line); + } + for (int i = 0; i < text.length; i++) { + lines.get(lines.size() - 1 - i).append(text[text.length - 1 - i]); + } + final int finalLength = lines.stream().mapToInt(StringBuilder::length).max().getAsInt(); + for (final StringBuilder line : lines) { + while (line.length() < finalLength) { + line.append(ROLLING_STOCK_SEPARATOR); + } + } + } + return lines.stream().map(StringBuilder::toString).collect(Collectors.toList()); + } + + @Override + public String toString() { + final StringBuilder stringBuilder = new StringBuilder(Integer.toString(getIdentifier())); + for (final RollingStock rollingStock : rollingStocks) { + stringBuilder.append(' '); + stringBuilder.append(rollingStock.getIdentifier()); + } + return stringBuilder.toString(); + } }