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.
 | 
					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.
 | 
					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:
 | 
					# Initialization:
 | 
				
			||||||
#### The game can be initialized by the terminal command:
 | 
					#### 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.
 | 
					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:
 | 
					#### 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
 | 
					## 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.*;
 | 
					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 {
 | 
					class CarTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +28,7 @@ class CarTest {
 | 
				
			||||||
    final char DEFAULT_ID = 'f';
 | 
					    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
 | 
					    @BeforeEach
 | 
				
			||||||
    void setUp() {
 | 
					    void setUp() {
 | 
				
			||||||
| 
						 | 
					@ -34,7 +36,7 @@ class CarTest {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Checks getID
 | 
					     * Checks if the method getID returns the correct value
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void getID() {
 | 
					    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 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 an exception is thrown and position kept unchanged if invalid coordinates are entered.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void setPosition() {
 | 
					    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
 | 
					    @Test
 | 
				
			||||||
    void crash() {
 | 
					    void crash() {
 | 
				
			||||||
| 
						 | 
					@ -169,8 +172,8 @@ class CarTest {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * test for methods setMoveStrategy. Checks if the MoveStrategy Object is saved and returned correctly
 | 
					     * Test for methods setMoveStrategy.
 | 
				
			||||||
     * with all Types of MoveStrategy.
 | 
					     * Checks if the MoveStrategy Object is saved and returned correctly with all Types of MoveStrategy.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void MoveStrategy() {
 | 
					    void MoveStrategy() {
 | 
				
			||||||
| 
						 | 
					@ -202,7 +205,7 @@ class CarTest {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Test for get WinPoints
 | 
					     * Tests if getWinPoints returns the correct value.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void getWinPoints() {
 | 
					    void getWinPoints() {
 | 
				
			||||||
| 
						 | 
					@ -210,7 +213,7 @@ class CarTest {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Test for increase WinPoints
 | 
					     * Tests if winpoints increase functions properly.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void increaseWinPoints() {
 | 
					    void increaseWinPoints() {
 | 
				
			||||||
| 
						 | 
					@ -219,7 +222,7 @@ class CarTest {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Test for deduct WinPoints
 | 
					     * Tests if the deductions of winpoints functions properly.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    void deductWinPoints() {
 | 
					    void deductWinPoints() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -160,7 +160,7 @@ class GameTest {
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        void winner() {
 | 
					        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,
 | 
				
			||||||
                RIGHT,
 | 
					                RIGHT,
 | 
				
			||||||
                NONE,
 | 
					                NONE,
 | 
				
			||||||
| 
						 | 
					@ -208,7 +208,7 @@ class GameTest {
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        void crashA() {
 | 
					        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();
 | 
					            game.initPhase();
 | 
				
			||||||
            Assertions.assertEquals("b",game.gamePhase());
 | 
					            Assertions.assertEquals("b",game.gamePhase());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -218,7 +218,7 @@ class GameTest {
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        void passFinishLineInWrongDirection() {
 | 
					        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();
 | 
					            game.initPhase();
 | 
				
			||||||
            Assertions.assertEquals("a",game.gamePhase());
 | 
					            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.
 | 
					     * 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.
 | 
					     * 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 PositionVector.Direction[] directions;
 | 
				
			||||||
        private final Integer[] instructions;
 | 
					        private final Integer[] instructions;
 | 
				
			||||||
        private int pointerDir,pointerInstruction;
 | 
					        private int pointerDir,pointerInstruction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public interFace(String welcometxt, Integer[] instructions, PositionVector.Direction[] directions) {
 | 
					        public Interface(String welcometext, Integer[] instructions, PositionVector.Direction[] directions) {
 | 
				
			||||||
            super(welcometxt);
 | 
					            super(welcometext);
 | 
				
			||||||
            pointerDir = -1;
 | 
					            pointerDir = -1;
 | 
				
			||||||
            pointerInstruction = -1;
 | 
					            pointerInstruction = -1;
 | 
				
			||||||
            this.instructions = instructions;
 | 
					            this.instructions = instructions;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,14 +10,18 @@ import java.io.FileNotFoundException;
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This Class tests the MoveStrategy.
 | 
					 * This Class tests the MoveStrategy.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class MoveStrategyTest {
 | 
					public class MoveListStrategyTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MoveStrategy moveList;
 | 
					    private MoveStrategy moveList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Nested
 | 
					    @Nested
 | 
				
			||||||
    @DisplayName("MoveListStrategy")
 | 
					    @DisplayName("MoveListStrategy")
 | 
				
			||||||
    class MoveList {
 | 
					    class MoveList {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Creates a new MoveListStrategy
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @BeforeEach
 | 
					        @BeforeEach
 | 
				
			||||||
        void setup() {
 | 
					        void setup() {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
| 
						 | 
					@ -27,6 +31,9 @@ public class MoveStrategyTest {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if the directions are returned correct by method nextMove
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        void checkMove() {
 | 
					        void checkMove() {
 | 
				
			||||||
            Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());
 | 
					            Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());
 | 
				
			||||||
		Loading…
	
		Reference in New Issue