Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						143b5da14c
					
				| 
						 | 
				
			
			@ -5,10 +5,12 @@ Racetrack is a pen and paper game that dates back to the early 1960s in this ver
 | 
			
		|||
The aim of the game is to finish the race faster than your opponent or win by being the only survivor in case the other cars crash.
 | 
			
		||||
 | 
			
		||||
In order to not crash you have to keep in mind the acceleration and other player's car to get to the finish line safely.
 | 
			
		||||
 | 
			
		||||
# Testing
 | 
			
		||||
#### All test can be run by the terminal command:
 | 
			
		||||
    gradlew test
 | 
			
		||||
# Initialization:
 | 
			
		||||
#### The game can be initialized by the terminal command:
 | 
			
		||||
    ./gradlew run
 | 
			
		||||
    gradlew run
 | 
			
		||||
You will then be prompted to select a track file from the selection by entering the corresponding number.
 | 
			
		||||
 | 
			
		||||
#### For each car that is taking part in the race a strategy has to be chosen there are the following options:
 | 
			
		||||
| 
						 | 
				
			
			@ -46,4 +48,4 @@ However, the classes that were already given, i.e. not editable, are also in the
 | 
			
		|||

 | 
			
		||||
 | 
			
		||||
## GitHub Project
 | 
			
		||||
Our GitHub Project can be found here: [GitHubProject](./projects/1)
 | 
			
		||||
Our GitHub Project can be found here: [GitHubProject](https://github.zhaw.ch/PM2-IT21bWIN-ruiz-mach-krea/team02-AngryNerds-projekt1-racetrack/projects)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,9 @@ import java.util.List;
 | 
			
		|||
import static org.junit.jupiter.api.Assertions.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Tests for Class Car
 | 
			
		||||
 * Class that contains all test for the Class Car
 | 
			
		||||
 *
 | 
			
		||||
 * @author Roman Schenk
 | 
			
		||||
 */
 | 
			
		||||
class CarTest {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +28,7 @@ class CarTest {
 | 
			
		|||
    final char DEFAULT_ID = 'f';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new Car Object and set Position to a defined Default Position
 | 
			
		||||
     * Creates a new Car Object and set Position to a defined Default Position
 | 
			
		||||
     */
 | 
			
		||||
    @BeforeEach
 | 
			
		||||
    void setUp() {
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +36,7 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks getID
 | 
			
		||||
     * Checks if the method getID returns the correct value
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void getID() {
 | 
			
		||||
| 
						 | 
				
			
			@ -52,8 +54,8 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * - checks if the position of the car can be set and saved correctly with valid positions.
 | 
			
		||||
     * - checks if an exception is thrown and position keeps unchanged if invalid coordinates are entered.
 | 
			
		||||
     * Checks if the position of the car can be set and saved correctly with valid positions.
 | 
			
		||||
     * Checks if an exception is thrown and position kept unchanged if invalid coordinates are entered.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void setPosition() {
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +161,8 @@ class CarTest {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * test for methods crash and isCrashed. checks if state crashed is set and returned correctly.
 | 
			
		||||
     * Test for methods crash and isCrashed.
 | 
			
		||||
     * Checks if state crashed is set and returned correctly.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void crash() {
 | 
			
		||||
| 
						 | 
				
			
			@ -169,8 +172,8 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * test for methods setMoveStrategy. Checks if the MoveStrategy Object is saved and returned correctly
 | 
			
		||||
     * with all Types of MoveStrategy.
 | 
			
		||||
     * Test for methods setMoveStrategy.
 | 
			
		||||
     * Checks if the MoveStrategy Object is saved and returned correctly with all Types of MoveStrategy.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void MoveStrategy() {
 | 
			
		||||
| 
						 | 
				
			
			@ -202,7 +205,7 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Test for get WinPoints
 | 
			
		||||
     * Tests if getWinPoints returns the correct value.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void getWinPoints() {
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +213,7 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Test for increase WinPoints
 | 
			
		||||
     * Tests if winpoints increase functions properly.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void increaseWinPoints() {
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +222,7 @@ class CarTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Test for deduct WinPoints
 | 
			
		||||
     * Tests if the deductions of winpoints functions properly.
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    void deductWinPoints() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -160,7 +160,7 @@ class GameTest {
 | 
			
		|||
         */
 | 
			
		||||
        @Test
 | 
			
		||||
        void winner() {
 | 
			
		||||
            game = new Game(new interFace("Test",new Integer[]{0,2,0},new PositionVector.Direction[]{RIGHT,
 | 
			
		||||
            game = new Game(new Interface("Test",new Integer[]{0,2,0},new PositionVector.Direction[]{RIGHT,
 | 
			
		||||
                RIGHT,
 | 
			
		||||
                RIGHT,
 | 
			
		||||
                NONE,
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ class GameTest {
 | 
			
		|||
         */
 | 
			
		||||
        @Test
 | 
			
		||||
        void crashA() {
 | 
			
		||||
            game = new Game(new interFace("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}), new Config());
 | 
			
		||||
            game = new Game(new Interface("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}), new Config());
 | 
			
		||||
            game.initPhase();
 | 
			
		||||
            Assertions.assertEquals("b",game.gamePhase());
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +218,7 @@ class GameTest {
 | 
			
		|||
         */
 | 
			
		||||
        @Test
 | 
			
		||||
        void passFinishLineInWrongDirection() {
 | 
			
		||||
            game = new Game(new interFace("Test",new Integer[]{1,0,1},new PositionVector.Direction[]{LEFT,NONE,NONE,RIGHT,RIGHT}), new Config());
 | 
			
		||||
            game = new Game(new Interface("Test",new Integer[]{1,0,1},new PositionVector.Direction[]{LEFT,NONE,NONE,RIGHT,RIGHT}), new Config());
 | 
			
		||||
            game.initPhase();
 | 
			
		||||
            Assertions.assertEquals("a",game.gamePhase());
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -241,15 +241,15 @@ class GameTest {
 | 
			
		|||
     * This Class is used to communicate with the UserInterface. It overrides crucial methods and returns an instruction based on the instructions' data field.
 | 
			
		||||
     * To implement the right instructions the user has to be aware of the game sequence.
 | 
			
		||||
     */
 | 
			
		||||
    private class interFace extends UserInterface {
 | 
			
		||||
    private class Interface extends UserInterface {
 | 
			
		||||
 | 
			
		||||
        private final PositionVector.Direction[] directions;
 | 
			
		||||
        private final Integer[] instructions;
 | 
			
		||||
        private int pointerDir,pointerInstruction;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public interFace(String welcometxt, Integer[] instructions, PositionVector.Direction[] directions) {
 | 
			
		||||
            super(welcometxt);
 | 
			
		||||
        public Interface(String welcometext, Integer[] instructions, PositionVector.Direction[] directions) {
 | 
			
		||||
            super(welcometext);
 | 
			
		||||
            pointerDir = -1;
 | 
			
		||||
            pointerInstruction = -1;
 | 
			
		||||
            this.instructions = instructions;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,14 +10,18 @@ import java.io.FileNotFoundException;
 | 
			
		|||
/**
 | 
			
		||||
 * This Class tests the MoveStrategy.
 | 
			
		||||
 */
 | 
			
		||||
public class MoveStrategyTest {
 | 
			
		||||
public class MoveListStrategyTest {
 | 
			
		||||
 | 
			
		||||
    private MoveStrategy moveList;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Nested
 | 
			
		||||
    @DisplayName("MoveListStrategy")
 | 
			
		||||
    class MoveList {
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Creates a new MoveListStrategy
 | 
			
		||||
         */
 | 
			
		||||
        @BeforeEach
 | 
			
		||||
        void setup() {
 | 
			
		||||
            try {
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +31,9 @@ public class MoveStrategyTest {
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Checks if the directions are returned correct by method nextMove
 | 
			
		||||
         */
 | 
			
		||||
        @Test
 | 
			
		||||
        void checkMove() {
 | 
			
		||||
            Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());
 | 
			
		||||
		Loading…
	
		Reference in New Issue