1 | package io.github.mathieusoysal; | |
2 | ||
3 | import java.util.stream.IntStream; | |
4 | ||
5 | import io.github.mathieusoysal.exception.IncorrectDiceValueException; | |
6 | ||
7 | /** | |
8 | * The {@code Dices} class represents a set of five dice used in the Yatzy game. | |
9 | * It allows you to store and manipulate the values of these dice. | |
10 | * | |
11 | * @see IntStream | |
12 | * @see IncorrectDiceValueException | |
13 | */ | |
14 | public class Dices { | |
15 | private int[] dicesArray; | |
16 | ||
17 | /** | |
18 | * Constructs a new {@code Dices} object with the values of five dice. | |
19 | * | |
20 | * @param dice1 The value of the first die. | |
21 | * @param dice2 The value of the second die. | |
22 | * @param dice3 The value of the third die. | |
23 | * @param dice4 The value of the fourth die. | |
24 | * @param dice5 The value of the fifth die. | |
25 | * @throws IncorrectDiceValueException If any of the dice values are not in the | |
26 | * valid range [1, 6]. | |
27 | */ | |
28 | public Dices(int dice1, int dice2, int dice3, int dice4, int dice5) { | |
29 | dicesArray = new int[] { dice1, dice2, dice3, dice4, dice5 }; | |
30 | for (int diceValue : dicesArray) | |
31 |
1
1. <init> : removed call to io/github/mathieusoysal/Dices::checkDiceValue → KILLED |
checkDiceValue(diceValue); |
32 | } | |
33 | ||
34 | /** | |
35 | * Checks if a given dice value is within the valid range [1, 6]. | |
36 | * | |
37 | * @param diceValue The value of the dice to check. | |
38 | * @throws IncorrectDiceValueException If the dice value is not in the valid | |
39 | * range [1, 6]. | |
40 | */ | |
41 | private void checkDiceValue(int diceValue) { | |
42 |
4
1. checkDiceValue : negated conditional → KILLED 2. checkDiceValue : negated conditional → KILLED 3. checkDiceValue : changed conditional boundary → KILLED 4. checkDiceValue : changed conditional boundary → KILLED |
if (diceValue < 1 || diceValue > 6) |
43 | throw new IncorrectDiceValueException(); | |
44 | } | |
45 | ||
46 | /** | |
47 | * Returns an {@link IntStream} of the dice values. | |
48 | * | |
49 | * @return An {@link IntStream} containing the values of the five dice. | |
50 | */ | |
51 | public IntStream getDicesIntStream() { | |
52 |
1
1. getDicesIntStream : replaced return value with null for io/github/mathieusoysal/Dices::getDicesIntStream → KILLED |
return IntStream.of(dicesArray); |
53 | } | |
54 | } | |
Mutations | ||
31 |
1.1 |
|
42 |
1.1 2.2 3.3 4.4 |
|
52 |
1.1 |