Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/main/java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java
This commit is contained in:
Leonardo Brandenberger 2022-03-25 22:04:18 +01:00
commit 6560de8708
3 changed files with 47 additions and 35 deletions

View File

@ -33,6 +33,7 @@ public final class PositionVector {
/**
* Adds two PositionVectors (e.g. car position and velocity vector or two velocity vectors).
*
* @param vectorA A position or velocity vector
* @param vectorB A position or velocity vector
* @return A new PositionVector holding the result of the addition. If both
@ -45,6 +46,7 @@ public final class PositionVector {
/**
* Subtracts two PositionVectors (e.g. car position and velocity vector or two velocity vectors).
*
* @param vectorA A position or velocity vector
* @param vectorB A position or velocity vector
* @return A new PositionVector holding the result of the addition. If both
@ -58,6 +60,7 @@ public final class PositionVector {
/**
* Calculates the scalar product (Skalarprodukt) of two 2D vectors. The scalar product
* multiplies the lengths of the parallel components of the vectors.
*
* @param vectorA A position or velocity vector
* @param vectorB A position or velocity vector
* @return The scalar product (vectorA * vectorB). Since vectorA and
@ -75,6 +78,7 @@ public final class PositionVector {
/**
* Copy constructor
*
* @param other
*/
public PositionVector(final PositionVector other) {

View File

@ -11,6 +11,7 @@ public class DoNotMoveStrategy implements MoveStrategy {
/**
* This method will be used to return the next Direction for the car.
*
* @return a NONE Direction
*/
@Override

View File

@ -23,6 +23,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Constructor which initialises the needed variables and creates the MoveList
*
* @param track track instance of the game
* @param carIndex index of the car which owns this moveStrategy
*/
@ -82,6 +83,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Method to check if a State is already in List calculatedStates
*
* @param state the State which should be checked
* @return true if it is in List, false if it isn't in List
*/
@ -103,6 +105,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Constructor of State
*
* @param position the PositionVector object with coordinates of the Position
* @param velocity the PositionVector object with coordinates of the Velocity
*/
@ -113,6 +116,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Checks if a state has the same Position and the same Velocity
*
* @param compareState the State object to compare
* @return true if it is equal, false if it is not equal
*/
@ -136,6 +140,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Constructor of PossibleMove
*
* @param previousMove The move which must be executed bevor this move can be executed
* @param nextDirection The direction of the move
*/
@ -149,8 +154,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
directions.addAll(previousMove.directions); //copy the LIst of Directions from the previousMove
startPosition = previousMove.endPosition; //use the endPosition from previousMove as startPosition
startVelocity = previousMove.endVelocity; //use the endVelocity from previousMove as startVelocity
}
else { //if there was no previousMove
} else { //if there was no previousMove
startPosition = track.getCarPos(carIndex); //use the current Position of the car from track as startPosition
startVelocity = track.getCar(carIndex).getVelocity(); //use the current Velocity of the car from track as startVelocity
}
@ -161,6 +165,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* check if the finishline is crossed (in correct direction) if this move is executed
*
* @return true if finishline will be crossed
*/
public boolean finished() {
@ -169,6 +174,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* checks if the car will crash or finishline will be crossed in wrong direction if this move is executed
*
* @return true if car will crash
*/
public boolean crashed() {
@ -187,6 +193,7 @@ public class PathFinderMoveStrategy implements MoveStrategy{
/**
* Checks if the next Move in moveList will crash. If no crash next move in moveList will be executed.
* If crash the moveList will be recreated.
*
* @return the direction of acceleration which should be executed.
*/
@Override