Game #23
			
				
			
		
		
		
	| 
						 | 
					@ -82,8 +82,7 @@ public class Game implements GameSpecification {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getCurrentCarIndex() {
 | 
					    public int getCurrentCarIndex() {
 | 
				
			||||||
        // TODO: implementation
 | 
					        return currentCarIndex;
 | 
				
			||||||
        throw new UnsupportedOperationException();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -163,8 +162,12 @@ public class Game implements GameSpecification {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void switchToNextActiveCar() {
 | 
					    public void switchToNextActiveCar() {
 | 
				
			||||||
        // TODO: implementation
 | 
					        do {
 | 
				
			||||||
        throw new UnsupportedOperationException();
 | 
					            if (currentCarIndex++ > track.getCarCount()) {
 | 
				
			||||||
 | 
					                currentCarIndex = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } while (track.getCar(currentCarIndex).isCrashed());
 | 
				
			||||||
 | 
					        // TODO: evtl andere Kapselung
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -181,7 +184,7 @@ public class Game implements GameSpecification {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<PositionVector> calculatePath(PositionVector startPosition, PositionVector endPosition) {
 | 
					    public List<PositionVector> calculatePath(PositionVector startPosition, PositionVector endPosition) {
 | 
				
			||||||
        ArrayList pathList = new ArrayList<PositionVector>();
 | 
					        ArrayList<PositionVector> pathList = new ArrayList<>();
 | 
				
			||||||
        // Use Bresenham's algorithm to determine positions.
 | 
					        // Use Bresenham's algorithm to determine positions.
 | 
				
			||||||
        int x = startPosition.getX();
 | 
					        int x = startPosition.getX();
 | 
				
			||||||
        int y = startPosition.getY();
 | 
					        int y = startPosition.getY();
 | 
				
			||||||
| 
						 | 
					@ -246,7 +249,13 @@ public class Game implements GameSpecification {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean willCarCrash(int carIndex, PositionVector position) {
 | 
					    public boolean willCarCrash(int carIndex, PositionVector position) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<PositionVector> positionList  = calculatePath(track.getCarPos(carIndex),position);
 | 
				
			||||||
 | 
					        for(PositionVector location : positionList) {
 | 
				
			||||||
 | 
					            if(track.willCrashAtPosition(location)) {
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue