Compare commits
2 Commits
main
...
update-cod
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b88b8681c | |||
| 0a5f32c883 |
@@ -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;
|
||||||
case SCISSORS -> other == PAPER;
|
case SCISSORS -> other == PAPER;
|
||||||
|
case WELL -> other == ROCK || other == SCISSORS;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ 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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user