@Override public void calculateTrainRoute(char point) { for (int i = 0; i < routeList.size(); i++) { TrainRoute trainRoute = routeList.get(i); if (trainRoute.getStartingPoint() == point) { if (!isLastElementSameAsLastThirdElementFromList(tempRouteList)) { numberOfStops++; tempRouteList.add(trainRoute); if (trainRoute.getEndingPoint() == destination) { if (shortestStops == 0 || numberOfStops < shortestStops) { shortestStops = numberOfStops; calculateLengthForShortestStops(); } numberOfStops--; tempRouteList.remove(lastElementIndex(tempRouteList)); } else { calculateTrainRoute(trainRoute.getEndingPoint()); } } } resetToPreviosLoopSettingsForLastIndex(i); } }
public TrainRoute getTrainRouteById(String id) { if (id == null) { throw new NullPointerException("TrainRoute.ID must not be null."); } for (TrainRoute tr : trainroutes) { if (tr.getId().equals(id)) { return tr; } } System.out.println("!!! TrainRoute [" + id + "] not found!"); return null; }