refactored merge conflict in Track
This commit is contained in:
		
							parent
							
								
									80b07111de
								
							
						
					
					
						commit
						eca2e2eb9b
					
				| 
						 | 
					@ -124,8 +124,8 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //TODO: THIS
 | 
					    //TODO: THIS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @throws InvalidTrackFormatException
 | 
					     * @throws InvalidTrackFormatException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void findFinish() throws InvalidTrackFormatException {
 | 
					    private void findFinish() throws InvalidTrackFormatException {
 | 
				
			||||||
| 
						 | 
					@ -183,19 +183,17 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
        track.add(positionVector.getY(), line);
 | 
					        track.add(positionVector.getY(), line);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //TODO: check if this method is okay and needed
 | 
					    //TODO: check if this method is okay and needed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Determines if a location is valid PositionVector inside the track
 | 
					     * Determines if a location is valid PositionVector inside the track
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param positionVector of location that has to be checked
 | 
					     * @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 {
 | 
					    private void isPositionVectorOnTrack(PositionVector positionVector) throws PositionVectorNotValidException {
 | 
				
			||||||
        try{
 | 
					        try {
 | 
				
			||||||
            track.get(positionVector.getY()).charAt(positionVector.getX());
 | 
					            track.get(positionVector.getY()).charAt(positionVector.getX());
 | 
				
			||||||
        }catch (IndexOutOfBoundsException e) {
 | 
					        } catch (IndexOutOfBoundsException e) {
 | 
				
			||||||
            throw new PositionVectorNotValidException();
 | 
					            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
 | 
					     * This Method will check if the Car would crash at the specific position
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param positionVector the position to check if the car would crash
 | 
					     * @param positionVector the position to check if the car could crash
 | 
				
			||||||
     * @return true if crash otherwise false
 | 
					     * @return true if car would crash. Else false.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public boolean willCrashAtPosition(int carIndex, PositionVector positionVector) throws PositionVectorNotValidException {
 | 
					    public boolean willCrashAtPosition(int carIndex, PositionVector positionVector) throws PositionVectorNotValidException {
 | 
				
			||||||
        isPositionVectorOnTrack(positionVector); //TODO: remove this line? Or Method?
 | 
					        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 carIndex            representing current Car
 | 
				
			||||||
     * @param crashPositionVector of the location of the crash
 | 
					     * @param crashPositionVector where the Crash did happen
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void carDoesCrash(int carIndex, PositionVector crashPositionVector) throws PositionVectorNotValidException {
 | 
					    public void carDoesCrash(int carIndex, PositionVector crashPositionVector) throws PositionVectorNotValidException {
 | 
				
			||||||
        isPositionVectorOnTrack(crashPositionVector); //TODO: remove this line? and Method?
 | 
					        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.
 | 
					     * If the location is outside the track bounds, it is considered a wall.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param position The coordinates of the position to examine
 | 
					     * @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
 | 
					    @Override
 | 
				
			||||||
    public Config.SpaceType getSpaceType(PositionVector position) {
 | 
					    public Config.SpaceType getSpaceType(PositionVector position) {
 | 
				
			||||||
| 
						 | 
					@ -303,13 +301,14 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
                return spaceType;
 | 
					                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
 | 
					    @Override
 | 
				
			||||||
    public int getCarCount() {
 | 
					    public int getCarCount() {
 | 
				
			||||||
| 
						 | 
					@ -383,13 +382,6 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
        return currentSpace.getValue();
 | 
					        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<PositionVector> calculatePointsOnPath(PositionVector startPosition, PositionVector endPosition) {
 | 
					    public ArrayList<PositionVector> calculatePointsOnPath(PositionVector startPosition, PositionVector endPosition) {
 | 
				
			||||||
        ArrayList<PositionVector> pathList = new ArrayList<>();
 | 
					        ArrayList<PositionVector> pathList = new ArrayList<>();
 | 
				
			||||||
        // Use Bresenham's algorithm to determine positions.
 | 
					        // Use Bresenham's algorithm to determine positions.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue