YMTwoPairs.java

1
package io.github.mathieusoysal.yatzy_mod;
2
3
import io.github.mathieusoysal.Dices;
4
5
/**
6
 * The {@code YMTwoPairs} class represents the "Two Pairs" scoring mod in the
7
 * Yatzy game.
8
 * In this category, players score by summing the values of the two highest
9
 * matching dice pairs.
10
 *
11
 * @author MathieuSoysal
12
 * @see YatzyModInterface
13
 */
14
class YMTwoPairs implements YatzyModInterface {
15
16
    /**
17
     * Calculates the score for the "Two Pairs" category.
18
     *
19
     * @param dices The set of dice to calculate the score for.
20
     * @return The calculated score, which is the sum of the two highest matching
21
     *         dice pairs, or zero if not possible.
22
     * @see YatzyModUtils#filterByFrequency(int, Dices)
23
     */
24
    @Override
25
    public int calculateScore(Dices dices) {
26 1 1. calculateScore : negated conditional → KILLED
        if (numberOfDistinctPairs(dices) == 2)
27 2 1. calculateScore : Replaced integer multiplication with division → KILLED
2. calculateScore : replaced int return with 0 for io/github/mathieusoysal/yatzy_mod/YMTwoPairs::calculateScore → KILLED
            return YatzyModUtils.filterByFrequency(2, dices).distinct().sum() * 2;
28
        else
29
            return 0;
30
    }
31
32
    /**
33
     * Counts the number of distinct pairs in the given set of dice.
34
     *
35
     * @param dices The set of dice to count pairs from.
36
     * @return The number of distinct pairs found in the dice set.
37
     * @see YatzyModUtils#filterByFrequency(int, Dices)
38
     */
39
    private int numberOfDistinctPairs(Dices dices) {
40 1 1. numberOfDistinctPairs : replaced int return with 0 for io/github/mathieusoysal/yatzy_mod/YMTwoPairs::numberOfDistinctPairs → KILLED
        return (int) YatzyModUtils.filterByFrequency(2, dices).distinct().count();
41
    }
42
}

Mutations

26

1.1
Location : calculateScore
Killed by : io.github.mathieusoysal.YatzyTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.YatzyTest]/[test-template:test_twoPairs(int, int, int, int, int, int)]/[test-template-invocation:#2]
negated conditional → KILLED

27

1.1
Location : calculateScore
Killed by : io.github.mathieusoysal.YatzyTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.YatzyTest]/[test-template:test_twoPairs(int, int, int, int, int, int)]/[test-template-invocation:#2]
Replaced integer multiplication with division → KILLED

2.2
Location : calculateScore
Killed by : io.github.mathieusoysal.YatzyTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.YatzyTest]/[test-template:test_twoPairs(int, int, int, int, int, int)]/[test-template-invocation:#2]
replaced int return with 0 for io/github/mathieusoysal/yatzy_mod/YMTwoPairs::calculateScore → KILLED

40

1.1
Location : numberOfDistinctPairs
Killed by : io.github.mathieusoysal.YatzyTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.YatzyTest]/[test-template:test_twoPairs(int, int, int, int, int, int)]/[test-template-invocation:#2]
replaced int return with 0 for io/github/mathieusoysal/yatzy_mod/YMTwoPairs::numberOfDistinctPairs → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0