5 Commits

Author SHA1 Message Date
5ced2b83e2 Update src/test/java/fr/iut_fbleau/info/but3/automation/rock_paper_scissors/play/spi/RandomCpuPickerTest.java
Change in the expected number of possible strokes and new possible stroke for the CPU
2025-11-29 19:55:45 +01:00
556908555a Update src/test/java/fr/iut_fbleau/info/but3/automation/rock_paper_scissors/play/domain/MoveTest.java
forgetting to change the expected number of possible moves
2025-11-29 19:50:50 +01:00
a96b007c1f Update src/main/java/fr/iut_fbleau/info/but3/automation/rock_paper_scissors/play/domain/Move.java 2025-11-29 19:48:26 +01:00
b4a28fdcf8 Update src/test/java/fr/iut_fbleau/info/but3/automation/rock_paper_scissors/play/domain/MoveTest.java
add the test ofr the WELL adding
2025-11-29 19:37:30 +01:00
699de02810 Update src/main/java/fr/iut_fbleau/info/but3/automation/rock_paper_scissors/play/domain/Move.java
add WELL in the game, the WELL loose in front of the PAPER and win against the ROCK and the SCISSORS.
2025-11-29 19:29:39 +01:00
3 changed files with 11 additions and 5 deletions

View File

@@ -3,13 +3,15 @@ package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain;
public enum Move { public enum Move {
ROCK, ROCK,
PAPER, PAPER,
SCISSORS; SCISSORS,
WELL;
public boolean beats(Move other) { public boolean beats(Move other) {
return switch (this) { return switch (this) {
case ROCK -> other == SCISSORS; case ROCK -> other == SCISSORS;
case PAPER -> other == ROCK; case PAPER -> (other == ROCK || other == WELL);
case SCISSORS -> other == PAPER; case SCISSORS -> other == PAPER;
case WELL -> (other == ROCK || other == SCISSORS);
}; };
} }
} }

View File

@@ -14,7 +14,7 @@ class MoveTest {
@Test @Test
void should_check_move_size(){ void should_check_move_size(){
Assertions.assertEquals(3, Move.values().length); Assertions.assertEquals(4, Move.values().length);
} }
@ParameterizedTest(name = "{0} should beat {1}") @ParameterizedTest(name = "{0} should beat {1}")
@@ -33,7 +33,10 @@ class MoveTest {
return Stream.of( return Stream.of(
Arguments.of(Move.ROCK,Move.SCISSORS), Arguments.of(Move.ROCK,Move.SCISSORS),
Arguments.of(Move.PAPER,Move.ROCK), Arguments.of(Move.PAPER,Move.ROCK),
Arguments.of(Move.SCISSORS,Move.PAPER) Arguments.of(Move.SCISSORS,Move.PAPER),
Arguments.of(Move.WELL,Move.SCISSORS),
Arguments.of(Move.WELL,Move.ROCK),
Arguments.of(Move.PAPER,Move.WELL)
); );
} }
} }

View File

@@ -20,9 +20,10 @@ class RandomCpuPickerTest {
obtainedMoves.add(picker.pick()); obtainedMoves.add(picker.pick());
} }
assertEquals(3, obtainedMoves.size()); assertEquals(4, obtainedMoves.size());
assertTrue(obtainedMoves.contains(Move.ROCK)); assertTrue(obtainedMoves.contains(Move.ROCK));
assertTrue(obtainedMoves.contains(Move.PAPER)); assertTrue(obtainedMoves.contains(Move.PAPER));
assertTrue(obtainedMoves.contains(Move.SCISSORS)); assertTrue(obtainedMoves.contains(Move.SCISSORS));
assertTrue(obtainedMoves.contains(Move.WELL));
} }
} }