forked from pierront/rock-paper-scissors
ajout du puit #1
@@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain;
|
package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
@@ -14,7 +13,8 @@ class MoveTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_check_move_size(){
|
void should_check_move_size(){
|
||||||
Assertions.assertEquals(3, Move.values().length);
|
// On a maintenant 4 coups : ROCK, PAPER, SCISSORS, WELL
|
||||||
|
assertEquals(4, Move.values().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} should beat {1}")
|
@ParameterizedTest(name = "{0} should beat {1}")
|
||||||
@@ -31,9 +31,12 @@ class MoveTest {
|
|||||||
|
|
||||||
static Stream<Arguments> winnable(){
|
static Stream<Arguments> winnable(){
|
||||||
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.PAPER, Move.WELL)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.spi;
|
package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.spi;
|
||||||
|
|
||||||
import fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain.Move;
|
import fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain.Move;
|
||||||
import fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.spi.RandomCpuPicker;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -20,9 +19,11 @@ class RandomCpuPickerTest {
|
|||||||
obtainedMoves.add(picker.pick());
|
obtainedMoves.add(picker.pick());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(3, obtainedMoves.size());
|
// Il doit maintenant pouvoir jouer 4 coups
|
||||||
|
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