Track feature #21
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -94,7 +94,7 @@ public class Track implements TrackSpecification {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void findCar() {
 | 
			
		||||
    public void addCar() {
 | 
			
		||||
        ConfigSpecification.SpaceType[] spaceTypes = ConfigSpecification.SpaceType.values();
 | 
			
		||||
        ArrayList<Character> allSpaceTypesAsChar = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,6 +113,19 @@ public class Track implements TrackSpecification {
 | 
			
		|||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private PositionVector findChar(char symbol) {
 | 
			
		||||
        PositionVector vector = null;
 | 
			
		||||
        for (int i = 0; i < track.size(); i++) {
 | 
			
		||||
            String line = track.get(i);
 | 
			
		||||
            for (int j = 0; j < line.length(); j++) {
 | 
			
		||||
                if (line.charAt(j) == symbol) {
 | 
			
		||||
                    vector = new PositionVector(j,i);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return vector;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void findFinish() {
 | 
			
		||||
        //TODO:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -155,8 +168,9 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getCarCount() {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        throw new UnsupportedOperationException();
 | 
			
		||||
        // TODO: error???
 | 
			
		||||
        return cars.size();
 | 
			
		||||
        //throw new UnsupportedOperationException();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -167,8 +181,9 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public Car getCar(int carIndex) {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        throw new UnsupportedOperationException();
 | 
			
		||||
        // TODO: error???
 | 
			
		||||
        return cars.get(carIndex);
 | 
			
		||||
        //throw new UnsupportedOperationException();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -179,8 +194,9 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public char getCarId(int carIndex) {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        throw new UnsupportedOperationException();
 | 
			
		||||
        // TODO: error???
 | 
			
		||||
        return cars.get(carIndex).getID();
 | 
			
		||||
        //throw new UnsupportedOperationException();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -191,8 +207,14 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public PositionVector getCarPos(int carIndex) {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        throw new UnsupportedOperationException();
 | 
			
		||||
        // TODO: nextPosition or Position of Trackfile?
 | 
			
		||||
        //Alternative 1
 | 
			
		||||
        return cars.get(carIndex).nextPosition();
 | 
			
		||||
 | 
			
		||||
        //Alternative 2 //NULL aussschliessen falls umgesetzt.
 | 
			
		||||
        return findChar(cars.get(carIndex).getID());
 | 
			
		||||
 | 
			
		||||
        //throw new UnsupportedOperationException();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -203,8 +225,9 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public PositionVector getCarVelocity(int carIndex) {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        throw new UnsupportedOperationException();
 | 
			
		||||
        // TODO: error???
 | 
			
		||||
        return cars.get(carIndex).getVelocity();
 | 
			
		||||
        //throw new UnsupportedOperationException();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -229,7 +252,7 @@ public class Track implements TrackSpecification {
 | 
			
		|||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        // TODO: implementation
 | 
			
		||||
        // TODO: error???
 | 
			
		||||
        String str = "";
 | 
			
		||||
        for (String line : track) {
 | 
			
		||||
            str += line+"\n";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,8 +44,8 @@ public class TrackTest {
 | 
			
		|||
 | 
			
		||||
    //TODO:
 | 
			
		||||
    @Test
 | 
			
		||||
    void findCarAtInit() {
 | 
			
		||||
        trackObj.findCar();
 | 
			
		||||
    void addCarAtInit() {
 | 
			
		||||
        trackObj.addCar();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue