forked from pierront/rock-paper-scissors
ajout puit
Some checks failed
rock-paper-scissors-jenkins/pipeline/head There was a failure building this commit
Some checks failed
rock-paper-scissors-jenkins/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -4,12 +4,14 @@ public enum Move {
|
|||||||
ROCK,
|
ROCK,
|
||||||
PAPER,
|
PAPER,
|
||||||
SCISSORS;
|
SCISSORS;
|
||||||
|
PUIT;
|
||||||
|
|
||||||
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 == PUIT;
|
||||||
case SCISSORS -> other == PAPER;
|
case SCISSORS -> other == PAPER;
|
||||||
|
case PUIT -> other == ROCK || other == SCISSORS;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.PUIT,Move.Rock),
|
||||||
|
Arguments.of(Move.PUIT,Move.SCISSORS),
|
||||||
|
Arguments.of(Move.PAPER.Move.PUIT)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.PUIT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user