code cleanup
This commit is contained in:
1 parent
e2c6b5cb49
commit
65d7ea6e7e
8 files changed
+78
-61
No files matched your search
+1
-4
@@ -1,4 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Do not edit this file with editors other than diagrams.net -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="3461px" height="2025px" viewBox="-0.5 -0.5 3461 2025" content="<mxfile host="Electron" modified="2022-03-25T19:21:10.260Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/17.2.1 Chrome/96.0.4664.174 Electron/16.1.0 Safari/537.36" etag="S4hkZBTjhgpoEeCGwcRv" version="17.2.1" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">7V1bd5pKG/41Wct9YRcnAS+N7rTZTZvs5tD26ltEibKLYAGT2F//zSAgMC8HEQY57IvdOALqPO/Me37mgp+u3z9aymb1xVyo+gXHLN4v+NkFx7EML6N/8MhuPyIK4/3A0tIW3kWHgXvtj+rf6Y1utYVqRy50TFN3tE10cG4ahjp3ImOKZZlv0cteTD36qRtlqRID93NFJ0e/awtn5Y2KI+HwxidVW678j2ZF7weuFf9q76fYK2VhvoWG+L8v+Kllms7+r/X7VNXx7PkT8/16912/+SV+/Odf+7fyePn54evTcP+wq2NuCX6DpRpO4Uf/+fVy9elJ+O/H5u7q3zfm4+T5n6F3C/Oq6Ftvwj4qa9X7vc7On0X7TVvrioFeXb6YhnPvvYOm4FLRtaWB/p6j76ZaaOBVtRwNATDx3nDMDRqdrzR9caPszC3+BbajzH/5ry5XpqX9QY9VdPQWiwbQ25bjyRInRq64x3eiYQaNWqqNrrnzp4UNhm4U2/GumZu6rmxs7dn9wviStWItNePSdBxz7T/I3BoLdeG9CnB2Xzi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TDCO7TKR3jpy0zMEAd1+qDjYK/3gS9RvPd6CTC8RixAMk85bUH1hfgGpAv+1x1GhNNu7EBDA/Kegro1m7nEdYF0AEIsemiw/p0nbTOeImGS4Pw0lGxpuI8Z+mBpVCM6lk3sS9ULd+ZT2PWODpjv5q2kmDk8eLRKirQ3ELh25dnIhQymTqbmV9NJzVt3wc/KAQ/RkLB4Edg2LU3+CHniEp33muTc4vckcGRtHM+TjM6wQq9FjoER0NzBhYnT9ni5HqLM1gXeZOdZ2ZxjoHTBhVndYWUsPmmWr2NUbeNIcvZNobAQDo/LVHaDhtjDJBszbcWxiDlAN3mKqVxGckUUFiqC1IBrFseRE+JzIKdggjIr9CFiGVIm26f8PISlR07UPp4CIFcCm0IgVhwa3KWxwMC8T9S3vf6pGUVuAIskiCulfm/rH9qRNQBTrKZo+nLC27qGrGJxkmjszQF4AR4y2lvnCCtRzvTaAXMR65ugMYdSUAXwGZUNzYsS2arzibgVFngCE6OZcWxSDE47UAnv22+hnhTQh/HOF7PLY2iz6i4DD6YktBW8Wj3IazaQ1gcP8oOYfFjKKTEtT6ExTKkghtukdheY6l7cRXL5DHyusFa7rBGTLine truncated
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="3461px" height="2026px" viewBox="-0.5 -0.5 3461 2026" content="<mxfile host="drawio-plugin" modified="2022-03-25T20:22:39.906Z" agent="5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" etag="q_0xtV0W7S17_0e8HHtc" version="14.7.4" type="embed"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">7V1bd5pKG/41Wct9YZccBLw0utNmN2mymzRtr75FlCi7CBYwif313wwCwszLURhU6EWjI3iY5515z89cCJPV+0dbXS9vrblmXPCD+fuFML3geU7ih+gPHtn6IwKn7EYWtj73x/YDD/ofzR8c+KMbfa45sQtdyzJcfR0fnFmmqc3c2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Oww1JZ/asqXUeBRBBqMIyC2KI4ZXVGvT3nLjUQURst9KNS+H+HX9y032L/PBydVd/zIl6x2JSOYWJp4ci0hQOVRP+7LccVplN+0FQlM78wgnjD6MIv/iHVAcTzQXJPCQAO9LbpoysRnupoB6p6p2JpkmEm22Bf9sRDgvV2jQDlW3CMucmCLBslJSgiXijRTSYKxbgKEYBiHR6G30tZNkcEckV3XWyNBAT170d7wC6jOWFMJ6CQmHIsoMPGqwLnNcoeMPNTpG2QZ3GdeoKmxEAht+SGED2Rm1uUoKnUTCjium6E7EqOtGZOHyEDRhokBLStj1HPNBSOKy8/N5RtAJML7UgkcIR/r6z4VaXqmCpxcUoNr2mhFdU9D3/D28U5x6jUdxPKDGRKZ4KB0bdg2wQm2M4D6d0jR+2DIDY9SkVu+tVfz1xug5mu+TziMUx4gDGPEZrz2wxACXgdzu0tVpZDTnjQ1geDDWU0DD9nmev10CHYC9my06XMDYmUB95s9lXeHSMLxUKNZUnuosPbAUiVE9Gxb2heqlPAuYzBrgbT6QlbtOPtDi4tEsG2jVLN7ViU1ggTbNlDck4zSDdN67EXfY9RwLTm+FThVOrS+Wm1qp0AV7GAR7SHHLHewJDdnzDfYoOaLwrfdSldwiVzAYlHYIy2FGNliUeIYOUGFojsDCFhhb2HxnYYfrIm9y98gs7BFwFKTqLq+QErbeNLuzMZq2MRQl28YQB5DOT0sMn4eNMQJ4xWYbG2OQctrx6SqlURXJI1BY6gvKAURjPkRPiWSKrYIIyCexhYgb0DbdLsHnJ2Zbdvp3cQiB3BFrCIHY99nkaIsDAlFeMt73uiRtHbgCxJkgrrX5v1xwUEbcAU6ymePp2gt+4hmxicbJSWelSsAJULWz3jhBJpPzTBuWMB/5pgEatSThXgKbYdPYcBydnTuagFNtgSM4GZgVx6LF4LAzrAKmgOM5iXdE1q/Lw/h71Fz2H05JZKv45nQhrMZDWLwwzA5hCSMopLine truncated
|
||||
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 113 KiB |
@@ -35,6 +35,3 @@ UP_RIGHT
|
||||
UP_RIGHT
|
||||
RIGHT
|
||||
RIGHT
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Game implements GameSpecification {
|
||||
|
||||
/**
|
||||
* This method will initialize the game. Therefore it interacts with the user via UserInterface
|
||||
*
|
||||
* @return true if the initialization is completed. Returns false if there is an error.
|
||||
*/
|
||||
public boolean initPhase() {
|
||||
@@ -70,35 +71,43 @@ public class Game implements GameSpecification {
|
||||
moveStrategy = new UserMoveStrategy(userInterface, i, track.getCarId(i));
|
||||
break;
|
||||
case 2:
|
||||
for(File file : config.getMoveDirectory().listFiles()){
|
||||
if(file.toString().equals(config.getMoveDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt")){
|
||||
for (File file : config.getMoveDirectory().listFiles()) {
|
||||
if (file.toString().equals(config.getMoveDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt")) {
|
||||
selectedFile = file;
|
||||
}
|
||||
}
|
||||
if(selectedFile != null){
|
||||
if (selectedFile != null) {
|
||||
try {
|
||||
moveStrategy = new MoveListStrategy(selectedFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
userInterface.printInformation("There is no Move-List implemented. Choose another Strategy!");
|
||||
e.printStackTrace();
|
||||
} catch (InvalidFileFormatException e) {
|
||||
userInterface.printInformation("Invalid Data in Move-List. Choose another Strategy and clean the File");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
userInterface.printInformation("There is no Move-List implemented. Choose another Strategy!");
|
||||
}
|
||||
|
||||
break;
|
||||
case 3:
|
||||
for(File file : config.getFollowerDirectory().listFiles()){
|
||||
if(file.toString().equals(config.getFollowerDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "_points.txt")){
|
||||
for (File file : config.getFollowerDirectory().listFiles()) {
|
||||
if (file.toString().equals(config.getFollowerDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "_points.txt")) {
|
||||
selectedFile = file;
|
||||
}
|
||||
}
|
||||
if(selectedFile != null){
|
||||
if (selectedFile != null) {
|
||||
try {
|
||||
moveStrategy = new PathFollowerMoveStrategy(selectedFile, track.getCarPos(currentCarIndex));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!");
|
||||
} catch (InvalidFileFormatException e) {
|
||||
e.printStackTrace();
|
||||
userInterface.printInformation("Invalid Point-List format. Change Strategy and clean Point-List");
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!");
|
||||
}
|
||||
|
||||
@@ -119,9 +128,10 @@ public class Game implements GameSpecification {
|
||||
|
||||
/**
|
||||
* The functionality was taken out of init to automate testing
|
||||
*
|
||||
* @param selectedTrack the Track which was selected by user
|
||||
*/
|
||||
Track selectTrack(File selectedTrack) throws InvalidTrackFormatException,FileNotFoundException {
|
||||
Track selectTrack(File selectedTrack) throws InvalidTrackFormatException, FileNotFoundException {
|
||||
track = new Track(selectedTrack);
|
||||
return track;
|
||||
}
|
||||
@@ -240,9 +250,9 @@ public class Game implements GameSpecification {
|
||||
}
|
||||
}
|
||||
int newWinPoints = track.calculateNewWinPoints(track.getCarPos(currentCarIndex), track.getCar(currentCarIndex).nextPosition());
|
||||
if(newWinPoints == 1){
|
||||
if (newWinPoints == 1) {
|
||||
track.getCar(currentCarIndex).increaseWinPoints();
|
||||
}else if(newWinPoints == -1){
|
||||
} else if (newWinPoints == -1) {
|
||||
track.getCar(currentCarIndex).deductWinPoints();
|
||||
}
|
||||
if (crashPosition != null) {
|
||||
@@ -265,7 +275,7 @@ public class Game implements GameSpecification {
|
||||
Direction direction;
|
||||
direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove();
|
||||
if (direction == null) {
|
||||
if(track.getCar(currentCarIndex).getMoveStrategy() instanceof UserMoveStrategy){
|
||||
if (track.getCar(currentCarIndex).getMoveStrategy() instanceof UserMoveStrategy) {
|
||||
quit = true;
|
||||
direction = Direction.NONE;
|
||||
} else {
|
||||
@@ -322,7 +332,8 @@ public class Game implements GameSpecification {
|
||||
* This method will check if a car is passing the finishline.
|
||||
* If the car is passing the finishline in the wrong direction, the car will lose a winpoint.
|
||||
* If the car is passing the finishline in the correct direction, the car will gain a winpoint.
|
||||
* @param start the startposition of the car
|
||||
*
|
||||
* @param start the startposition of the car
|
||||
* @param finish the expected finishpositon of the car after the move
|
||||
*/
|
||||
private void calculateWinner(PositionVector start, PositionVector finish, int carIndex) {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Track implements TrackSpecification {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the finish line and saves it in a list, throws an Exception if none is found.
|
||||
* Determines the finish line and saves it in a list, throws an Exception if none is found.
|
||||
*
|
||||
* @throws InvalidTrackFormatException thrown if no finish line is found
|
||||
*/
|
||||
@@ -256,7 +256,7 @@ public class Track implements TrackSpecification {
|
||||
/**
|
||||
* This Method will mark the Car as crashed inside the track and the car Object.
|
||||
*
|
||||
* @param carIndex of car that will be marked as crashed
|
||||
* @param carIndex of car that will be marked as crashed
|
||||
* @param crashPositionVector of the location of the crash
|
||||
*/
|
||||
public void carDoesCrash(int carIndex, PositionVector crashPositionVector) {
|
||||
@@ -369,7 +369,7 @@ public class Track implements TrackSpecification {
|
||||
* 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
|
||||
* @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) {
|
||||
@@ -436,7 +436,7 @@ public class Track implements TrackSpecification {
|
||||
* If the car is passing the finish line in the wrong direction, the car will lose a winpoint.
|
||||
* If the car is passing the finish line in the correct direction, the car will gain a winpoint.
|
||||
*
|
||||
* @param start the start position of the car
|
||||
* @param start the start position of the car
|
||||
* @param finish the expected finish position of the car after the move
|
||||
* @return Number of new winpoints for the current player.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.pm2.racetrack.strategy;
|
||||
|
||||
import ch.zhaw.pm2.racetrack.InvalidFileFormatException;
|
||||
import ch.zhaw.pm2.racetrack.PositionVector.Direction;
|
||||
|
||||
import java.io.File;
|
||||
@@ -13,14 +14,13 @@ import java.util.Scanner;
|
||||
/**
|
||||
* This Class represent the MoveListStrategy. The Directions returned by the
|
||||
* nextMove() are written down in a List.
|
||||
*
|
||||
*/
|
||||
public class MoveListStrategy implements MoveStrategy {
|
||||
|
||||
private final List<Direction> moveList;
|
||||
private int pointer;
|
||||
|
||||
public MoveListStrategy(File moveListFile) throws FileNotFoundException{
|
||||
public MoveListStrategy(File moveListFile) throws FileNotFoundException, InvalidFileFormatException {
|
||||
moveList = new ArrayList<>();
|
||||
pointer = -1;
|
||||
readFile(moveListFile);
|
||||
@@ -29,25 +29,32 @@ public class MoveListStrategy implements MoveStrategy {
|
||||
/**
|
||||
* This Method will read in a File and checks line by line if the file contains a valid direction.
|
||||
* If so the direction will be added to the moveList.
|
||||
*
|
||||
* @param trackFile the file to read in the directions
|
||||
* @throws FileNotFoundException if the file does not exist.
|
||||
*/
|
||||
private void readFile(File trackFile) throws FileNotFoundException {
|
||||
private void readFile(File trackFile) throws FileNotFoundException, InvalidFileFormatException {
|
||||
Scanner scanner = new Scanner(new FileInputStream(trackFile), StandardCharsets.UTF_8);
|
||||
Direction[] directions = Direction.values();
|
||||
while (scanner.hasNextLine()) {
|
||||
boolean validLine = false;
|
||||
String line = scanner.nextLine();
|
||||
for (Direction direction : directions) {
|
||||
if (direction.toString().equals(line)) {
|
||||
moveList.add(direction);
|
||||
validLine = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(validLine || line == "")) {
|
||||
throw new InvalidFileFormatException("The File contains invalid data! Please ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return the next Direction for the car.
|
||||
*
|
||||
* @return the next direction from the list. Returns null if the list is empty.
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.pm2.racetrack.strategy;
|
||||
|
||||
import ch.zhaw.pm2.racetrack.InvalidFileFormatException;
|
||||
import ch.zhaw.pm2.racetrack.PositionVector;
|
||||
import ch.zhaw.pm2.racetrack.PositionVector.Direction;
|
||||
|
||||
@@ -34,11 +35,12 @@ public class PathFollowerMoveStrategy implements MoveStrategy {
|
||||
|
||||
/**
|
||||
* Constructor to create a new PathFollowerMoveStrategy for a car.
|
||||
* @param trackFile The location where the file is saved
|
||||
*
|
||||
* @param trackFile The location where the file is saved
|
||||
* @param startPosition The start position of the car
|
||||
* @throws FileNotFoundException If the file with the given path does not exist.
|
||||
*/
|
||||
public PathFollowerMoveStrategy(File trackFile, PositionVector startPosition) throws FileNotFoundException {
|
||||
public PathFollowerMoveStrategy(File trackFile, PositionVector startPosition) throws FileNotFoundException, InvalidFileFormatException {
|
||||
pointList = new ArrayList<>();
|
||||
pointer = 0;
|
||||
readFile(trackFile);
|
||||
@@ -48,20 +50,26 @@ public class PathFollowerMoveStrategy implements MoveStrategy {
|
||||
|
||||
/**
|
||||
* Method to read the given File and add the points to the pointList
|
||||
*
|
||||
* @param trackFile the File Object which should be read
|
||||
* @throws FileNotFoundException If the file with the given path does not exist.
|
||||
*/
|
||||
public void readFile(File trackFile) throws FileNotFoundException {
|
||||
public void readFile(File trackFile) throws FileNotFoundException, InvalidFileFormatException {
|
||||
Scanner scanner = new Scanner(new FileInputStream(trackFile), StandardCharsets.UTF_8);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] coordinates = line.split("(\\(X:|, Y:|\\))");
|
||||
pointList.add(new PositionVector(Integer.parseInt(coordinates[1]), Integer.parseInt(coordinates[2])));
|
||||
try {
|
||||
pointList.add(new PositionVector(Integer.parseInt(coordinates[1]), Integer.parseInt(coordinates[2])));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidFileFormatException("Invalid File Format");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to select the direction for the next move.
|
||||
*
|
||||
* @return The direction for the next move. null if there are no points left in the list.
|
||||
*/
|
||||
@Override
|
||||
@@ -73,7 +81,7 @@ public class PathFollowerMoveStrategy implements MoveStrategy {
|
||||
|
||||
// increase pointer variable if the next point is reached.
|
||||
if (pointList.get(pointer).equals(currentPosition)) {
|
||||
pointer ++;
|
||||
pointer++;
|
||||
}
|
||||
|
||||
// calculate Vector from current Position to next Point
|
||||
@@ -81,31 +89,29 @@ public class PathFollowerMoveStrategy implements MoveStrategy {
|
||||
|
||||
// select acceleration for X
|
||||
int accelerationX;
|
||||
if((movementVector.getX() == 0 && currentVelocity.getX() > 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getX() > 0 && movementVector.getX()/2.0 <= currentVelocity.getX()) || //increase velocity
|
||||
(movementVector.getX() < 0 && movementVector.getX()/2.0 < currentVelocity.getX())){ //reduce velocity
|
||||
accelerationX = -1;
|
||||
} else if((movementVector.getX() == 0 && currentVelocity.getX() < 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getX() > 0 && movementVector.getX()/2.0 > currentVelocity.getX()) || //increase velocity
|
||||
(movementVector.getX() < 0 && movementVector.getX()/2.0 >= currentVelocity.getX())) { //reduce velocity
|
||||
accelerationX = 1;
|
||||
}
|
||||
else { //no acceleration
|
||||
if ((movementVector.getX() == 0 && currentVelocity.getX() > 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getX() > 0 && movementVector.getX() / 2.0 <= currentVelocity.getX()) || //increase velocity
|
||||
(movementVector.getX() < 0 && movementVector.getX() / 2.0 < currentVelocity.getX())) { //reduce velocity
|
||||
accelerationX = -1;
|
||||
} else if ((movementVector.getX() == 0 && currentVelocity.getX() < 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getX() > 0 && movementVector.getX() / 2.0 > currentVelocity.getX()) || //increase velocity
|
||||
(movementVector.getX() < 0 && movementVector.getX() / 2.0 >= currentVelocity.getX())) { //reduce velocity
|
||||
accelerationX = 1;
|
||||
} else { //no acceleration
|
||||
accelerationX = 0;
|
||||
}
|
||||
|
||||
// select acceleration for Y
|
||||
int accelerationY;
|
||||
if((movementVector.getY() == 0 && currentVelocity.getY() > 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getY() > 0 && movementVector.getY()/2.0 <= currentVelocity.getY()) || //increase velocity
|
||||
(movementVector.getY() < 0 && movementVector.getY()/2.0 < currentVelocity.getY())){ //reduce velocity
|
||||
accelerationY = -1;
|
||||
} else if((movementVector.getY() == 0 && currentVelocity.getY() < 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getY() > 0 && movementVector.getY()/2.0 > currentVelocity.getY()) || //increase velocity
|
||||
(movementVector.getY() < 0 && movementVector.getY()/2.0 >= currentVelocity.getY())) { //reduce velocity
|
||||
accelerationY = 1;
|
||||
}
|
||||
else { //no acceleration
|
||||
if ((movementVector.getY() == 0 && currentVelocity.getY() > 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getY() > 0 && movementVector.getY() / 2.0 <= currentVelocity.getY()) || //increase velocity
|
||||
(movementVector.getY() < 0 && movementVector.getY() / 2.0 < currentVelocity.getY())) { //reduce velocity
|
||||
accelerationY = -1;
|
||||
} else if ((movementVector.getY() == 0 && currentVelocity.getY() < 0) || //reduce velocity to 0 if the destination coordinate is reached
|
||||
(movementVector.getY() > 0 && movementVector.getY() / 2.0 > currentVelocity.getY()) || //increase velocity
|
||||
(movementVector.getY() < 0 && movementVector.getY() / 2.0 >= currentVelocity.getY())) { //reduce velocity
|
||||
accelerationY = 1;
|
||||
} else { //no acceleration
|
||||
accelerationY = 0;
|
||||
}
|
||||
|
||||
@@ -121,7 +127,7 @@ public class PathFollowerMoveStrategy implements MoveStrategy {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,6 @@ class CarTest {
|
||||
checkNextPosition(DEFAULT_X, DEFAULT_Y);
|
||||
|
||||
|
||||
|
||||
for (PositionVector.Direction direction1 : directions) {
|
||||
for (PositionVector.Direction direction2 : directions) {
|
||||
|
||||
@@ -180,7 +179,7 @@ class CarTest {
|
||||
|
||||
try {
|
||||
moveStrategy = new MoveListStrategy(new File(".\\moves\\challenge-car-a.txt"));
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (FileNotFoundException | InvalidFileFormatException e) {
|
||||
Assertions.fail();
|
||||
}
|
||||
car.setMoveStrategy(moveStrategy);
|
||||
@@ -188,13 +187,13 @@ class CarTest {
|
||||
|
||||
try {
|
||||
moveStrategy = new PathFollowerMoveStrategy(new File(".\\follower\\challenge_points.txt"), new PositionVector(0, 0));
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (FileNotFoundException | InvalidFileFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
car.setMoveStrategy(moveStrategy);
|
||||
assertEquals(moveStrategy, car.getMoveStrategy());
|
||||
|
||||
moveStrategy = new UserMoveStrategy(new UserInterface("Hello"),0,'a');
|
||||
moveStrategy = new UserMoveStrategy(new UserInterface("Hello"), 0, 'a');
|
||||
car.setMoveStrategy(moveStrategy);
|
||||
assertEquals(moveStrategy, car.getMoveStrategy());
|
||||
}
|
||||
@@ -204,7 +203,7 @@ class CarTest {
|
||||
*/
|
||||
@Test
|
||||
void getWinPoints() {
|
||||
assertEquals(0,car.getWinPoints());
|
||||
assertEquals(0, car.getWinPoints());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +212,7 @@ class CarTest {
|
||||
@Test
|
||||
void increaseWinPoints() {
|
||||
car.increaseWinPoints();
|
||||
assertEquals(1,car.getWinPoints());
|
||||
assertEquals(1, car.getWinPoints());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +221,7 @@ class CarTest {
|
||||
@Test
|
||||
void deductWinPoints() {
|
||||
car.deductWinPoints();
|
||||
assertEquals(-1,car.getWinPoints());
|
||||
assertEquals(-1, car.getWinPoints());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class MoveStrategyTest {
|
||||
void setup() {
|
||||
try {
|
||||
moveList = new MoveListStrategy(new File(".\\moves\\challenge-car-a.txt"));
|
||||
}catch (FileNotFoundException e) {
|
||||
}catch (FileNotFoundException | InvalidFileFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user