ajout puit

This commit is contained in:
2025-11-27 10:10:51 +01:00
parent 9b1af5029f
commit 7b12223ac6
3 changed files with 9 additions and 4 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 || other == WELL;
case PAPER -> other == ROCK; case PAPER -> other == ROCK;
case SCISSORS -> other == PAPER; case SCISSORS -> other == PAPER || other == WELL;
case WELL -> other == PAPER;
}; };
} }
} }

View File

@@ -46,7 +46,9 @@ public class PlayControllerTest {
public static Stream<Arguments> scenario() { public static Stream<Arguments> scenario() {
return Stream.of( return Stream.of(
Arguments.of(Move.ROCK, Move.SCISSORS, WIN), Arguments.of(Move.ROCK, Move.SCISSORS, WIN),
Arguments.of(Move.ROCK, Move.PAPER, LOOSE) Arguments.of(Move.ROCK, Move.PAPER, LOOSE),
Arguments.of(Move.WELL, Move.PAPER, LOOSE),
Arguments.of(Move.ROCK, Move.WELL, WIN)
); );
} }

View File

@@ -24,5 +24,6 @@ class RandomCpuPickerTest {
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));
} }
} }