From c4f2659035d038e6765488937c5fe778836ab845 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Fri, 6 Mar 2020 13:01:22 +0100 Subject: [PATCH] Checkstyle --- src/edu/kit/informatik/model/TrainManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/edu/kit/informatik/model/TrainManager.java b/src/edu/kit/informatik/model/TrainManager.java index 73aa75c..9417140 100644 --- a/src/edu/kit/informatik/model/TrainManager.java +++ b/src/edu/kit/informatik/model/TrainManager.java @@ -146,12 +146,13 @@ public final class TrainManager { } /** - * Place a train on the rail network. + * Attempt to place a train on the rail network. + * * @param trainId identifier of the train to place * @param position where to place the train * @param direction direction in which the train should initially go * @return whether the train was successfully placed - * @throws InvalidInputException when the train is too long + * @throws InvalidInputException if train could not be placed due to semantic error */ public boolean putTrain(int trainId, Vector2D position, Vector2D direction) throws InvalidInputException { final Train train = trains.get(trainId); @@ -168,7 +169,7 @@ public final class TrainManager { } // attempt to place train final boolean placed = train.placeOn(railNetwork, position, direction); - // check for collisions + // check for collisions with existing trains if (placed && !getPlacementCollisions().isEmpty()) { train.removeFromRails(); return false; @@ -178,7 +179,7 @@ public final class TrainManager { } /** - * Calculate the next train identifier. + * Calculate the next available train identifier. * @return the next train identifier, or -1 if none available */ private int getNextTrainIdentifier() { @@ -222,7 +223,7 @@ public final class TrainManager { private List> getPlacementCollisions() { final List> collisions = new ArrayList<>(); trains.values().stream().filter(Train::isPlaced).forEach(train1 -> - trains.values().stream().filter(train -> train != train1).filter(Train::isPlaced).forEach(train2 -> { + trains.values().stream().filter(Train::isPlaced).forEach(train2 -> { final Set occupiedByTrain1 = train1.getOccupiedRails(); Collections.addAll(occupiedByTrain1, railNetwork.findTouchingRails(train1.getFrontPosition())); Collections.addAll(occupiedByTrain1, railNetwork.findTouchingRails(train1.getRearPosition()));