Game #23
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -24,6 +24,10 @@ public class Car implements CarSpecification {
 | 
			
		|||
     * Current position of the car on the track grid using a {@link PositionVector}
 | 
			
		||||
     */
 | 
			
		||||
    private PositionVector position;
 | 
			
		||||
    /**
 | 
			
		||||
     * Points that car is holding for determining winner.
 | 
			
		||||
     */
 | 
			
		||||
    private int winPoints;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Current velocity of the car using a {@link PositionVector}
 | 
			
		||||
| 
						 | 
				
			
			@ -59,6 +63,18 @@ public class Car implements CarSpecification {
 | 
			
		|||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void increaseWinPoints() {
 | 
			
		||||
        winPoints ++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void deductWinPoints() {
 | 
			
		||||
        winPoints --;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getWinPoints() {
 | 
			
		||||
        return winPoints;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the current velocity of the car as a PositionVector.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -266,44 +266,44 @@ public class Game implements GameSpecification {
 | 
			
		|||
        return pathList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void calculateWinner(PositionVector start, PositionVector finish, int carIndex ){
 | 
			
		||||
    private void calculateWinner(PositionVector start, PositionVector finish, int carIndex ) {
 | 
			
		||||
        List<PositionVector> path = calculatePath(start, finish);
 | 
			
		||||
        for (PositionVector point : path){
 | 
			
		||||
            switch (track.getSpaceType(point)) {
 | 
			
		||||
                case FINISH_UP:
 | 
			
		||||
                    if(start.getY() < finish.getY()) {
 | 
			
		||||
                        //track.getCar(carIndex).addWinPoint;
 | 
			
		||||
                        //TODO: add point
 | 
			
		||||
                        track.getCar(carIndex).increaseWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    else if( start.getY() < finish.getY()) {
 | 
			
		||||
                        //TODO: deduct point
 | 
			
		||||
                    else if(start.getY() < finish.getY()) {
 | 
			
		||||
                        track.getCar(carIndex).deductWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case FINISH_DOWN:
 | 
			
		||||
                    if(start.getY() > finish.getY()){
 | 
			
		||||
                        //track.getCar(carIndex).addWinPoint;
 | 
			
		||||
                        track.getCar(carIndex).increaseWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (start.getY() < finish.getY()){
 | 
			
		||||
 | 
			
		||||
                        track.getCar(carIndex).deductWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case FINISH_RIGHT:
 | 
			
		||||
                    if(start.getX() < finish.getX()){
 | 
			
		||||
                        //track.getCar(carIndex).addWinPoint;
 | 
			
		||||
                        track.getCar(carIndex).increaseWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (start.getX() < finish.getX()){
 | 
			
		||||
 | 
			
		||||
                        track.getCar(carIndex).deductWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case  FINISH_LEFT:
 | 
			
		||||
                    if(start.getX() > finish.getX()){
 | 
			
		||||
                        //track.getCar(carIndex).addWinPoint;
 | 
			
		||||
                        track.getCar(carIndex).increaseWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (start.getX() < finish.getX()){
 | 
			
		||||
 | 
			
		||||
                        track.getCar(carIndex).increaseWinPoints();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue