diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Track.java b/src/main/java/ch/zhaw/pm2/racetrack/Track.java index d2d8036..02ddd9a 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Track.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Track.java @@ -124,8 +124,8 @@ public class Track implements TrackSpecification { } //TODO: THIS + /** - * * @throws InvalidTrackFormatException */ private void findFinish() throws InvalidTrackFormatException { @@ -174,7 +174,7 @@ public class Track implements TrackSpecification { * Method that places a character at a chosen position * * @param positionVector position where char will be placed - * @param symbol char that should be placed at desired position + * @param symbol char that should be placed at desired position */ private void drawCharOnTrackIndicator(PositionVector positionVector, char symbol) { String line = track.get(positionVector.getY()); @@ -183,19 +183,17 @@ public class Track implements TrackSpecification { track.add(positionVector.getY(), line); } //TODO: check if this method is okay and needed + /** * Determines if a location is valid PositionVector inside the track * * @param positionVector of location that has to be checked - * @throws PositionVectorNotValid if the PositionVector does not lie on the track. + * @throws PositionVectorNotValidException if the PositionVector does not lie on the track. */ - private void isPositionVectorOnTrack(PositionVector positionVector) throws PositionVectorNotValid { - try { - private void isPositionVectorOnTrack(PositionVector positionVector) throws PositionVectorNotValidException { - try{ + try { track.get(positionVector.getY()).charAt(positionVector.getX()); - }catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new PositionVectorNotValidException(); } } @@ -256,8 +254,8 @@ public class Track implements TrackSpecification { /** * This Method will check if the Car would crash at the specific position * - * @param positionVector the position to check if the car would crash - * @return true if crash otherwise false + * @param positionVector the position to check if the car could crash + * @return true if car would crash. Else false. */ public boolean willCrashAtPosition(int carIndex, PositionVector positionVector) throws PositionVectorNotValidException { isPositionVectorOnTrack(positionVector); //TODO: remove this line? Or Method? @@ -271,10 +269,10 @@ public class Track implements TrackSpecification { } /** - * This Method will mark the Car as crashed inside the track and the car Object. + * This Method will make the Car Crash. In Track and in the Car Object * - * @param carIndex of car that will be marked as crashed - * @param crashPositionVector of the location of the crash + * @param carIndex representing current Car + * @param crashPositionVector where the Crash did happen */ public void carDoesCrash(int carIndex, PositionVector crashPositionVector) throws PositionVectorNotValidException { isPositionVectorOnTrack(crashPositionVector); //TODO: remove this line? and Method? @@ -291,7 +289,7 @@ public class Track implements TrackSpecification { * If the location is outside the track bounds, it is considered a wall. * * @param position The coordinates of the position to examine - * @return The type of space at the desired position + * @return The type of track position at the given location */ @Override public Config.SpaceType getSpaceType(PositionVector position) { @@ -303,13 +301,14 @@ public class Track implements TrackSpecification { return spaceType; } } - return ConfigSpecification.SpaceType.WALL; + + return null; } /** - * Return the number of cars that are located in a track + * Return the number of cars. * - * @return number of cars as int + * @return Number of cars */ @Override public int getCarCount() { @@ -383,13 +382,6 @@ public class Track implements TrackSpecification { return currentSpace.getValue(); } - /** - * Determines all points that lie between the two position vectors including the endpoint VectorPosition using the Bresenham algorithm. - * - * @param startPosition PositionVector of the finish coordinate - * @param endPosition PositionVector of the start coordinate - * @return ArrayList containing PositionVectors of all position that are between the start and finish including the finish position. - */ public ArrayList calculatePointsOnPath(PositionVector startPosition, PositionVector endPosition) { ArrayList pathList = new ArrayList<>(); // Use Bresenham's algorithm to determine positions.