Track feature #21
			
				
			
		
		
		
	| 
						 | 
					@ -193,15 +193,21 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
        //Adds Car at new Position
 | 
					        //Adds Car at new Position
 | 
				
			||||||
        positionVector = cars.get(carIndex).nextPosition();
 | 
					        positionVector = cars.get(carIndex).nextPosition();
 | 
				
			||||||
        line = track.get(positionVector.getY());
 | 
					        line = track.get(positionVector.getY());
 | 
				
			||||||
        line = line.substring(0,positionVector.getX()) + cars.get(carIndex).getId() + line.substring(positionVector.getX()+1);
 | 
					        line = line.substring(0,positionVector.getX()) + cars.get(carIndex).getID() + line.substring(positionVector.getX()+1);
 | 
				
			||||||
        track.add(positionVector.getY(),line);
 | 
					        track.add(positionVector.getY(),line);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Change position of car
 | 
					        //Change position of car
 | 
				
			||||||
        getCar(carIndex).move();
 | 
					        getCar(carIndex).move();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public char getRealCharAtPosition(PositionVector positionVector) {
 | 
					    /**
 | 
				
			||||||
        return track.get(positionVector.getY()).charAt(positionVector.getX());
 | 
					     * This Method will check if the Car could crash at the specific position
 | 
				
			||||||
 | 
					     * @param positionVector the position to check if the car could crash
 | 
				
			||||||
 | 
					     * @return true if car would crash. Else false.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean willCrashAtPosition(PositionVector positionVector) {
 | 
				
			||||||
 | 
					        char charAtPosition = track.get(positionVector.getY()).charAt(positionVector.getX());
 | 
				
			||||||
 | 
					        return charAtPosition != ConfigSpecification.SpaceType.TRACK.value;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -255,7 +261,7 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public char getCarId(int carIndex) {
 | 
					    public char getCarId(int carIndex) {
 | 
				
			||||||
        return cars.get(carIndex).getId();
 | 
					        return cars.get(carIndex).getID();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -267,7 +273,7 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public PositionVector getCarPos(int carIndex) {
 | 
					    public PositionVector getCarPos(int carIndex) {
 | 
				
			||||||
        return findChar(cars.get(carIndex).getId());
 | 
					        return findChar(cars.get(carIndex).getID());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -294,7 +300,7 @@ public class Track implements TrackSpecification {
 | 
				
			||||||
    public char getCharAtPosition(int y, int x, Config.SpaceType currentSpace) {
 | 
					    public char getCharAtPosition(int y, int x, Config.SpaceType currentSpace) {
 | 
				
			||||||
        char charAtPos = track.get(y).charAt(x);
 | 
					        char charAtPos = track.get(y).charAt(x);
 | 
				
			||||||
        for (Car car : cars) {
 | 
					        for (Car car : cars) {
 | 
				
			||||||
            if(charAtPos == car.getId()) {
 | 
					            if(charAtPos == car.getID()) {
 | 
				
			||||||
                if(car.isCrashed()) {
 | 
					                if(car.isCrashed()) {
 | 
				
			||||||
                    return CRASH_INDICATOR;
 | 
					                    return CRASH_INDICATOR;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue