dick #1

Merged
Adrien DICK merged 5 commits from dick into main 2025-11-27 11:40:58 +01:00
3 changed files with 9 additions and 6 deletions
Showing only changes of commit 59c7378784 - Show all commits

View File

@@ -8,9 +8,9 @@ public enum Move {
public boolean beats(Move other) { public boolean beats(Move other) {
return switch (this) { return switch (this) {
case ROCK -> other == SCISSORS || other == WELL; case ROCK -> other == SCISSORS;
case PAPER -> other == ROCK; case PAPER -> other == ROCK || other == WELL;
case SCISSORS -> other == PAPER || other == WELL; case SCISSORS -> other == PAPER;
case WELL -> other == PAPER; case WELL -> other == PAPER;
}; };
} }

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.ROCK),
Arguments.of(Move.WELL,Move.SCISSORS),
Arguments.of(Move.WELL,Move.PAPER)
); );
} }
} }

View File

@@ -20,7 +20,7 @@ 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));