Day2.java

1
package com.roxoft.aoc.y2015.Day2;
2
3
import java.util.Objects;
4
import java.util.stream.Stream;
5
6
public final class Day2 {
7
    /** Length of box. */
8
    private final int l;
9
    /** Width of box. */
10
    private final int w;
11
    /** Height of box. */
12
    private final int h;
13
14
    /** Surface area of side A. */
15
    private final int sideA;
16
    /** Surface area of side B. */
17
    private final int sideB;
18
    /** Surface area of side C. */
19
    private final int sideC;
20
21
    private Day2(final int length,
22
                 final int width,
23
                 final int height) {
24
        l = length;
25
        w = width;
26
        h = height;
27
28 1 1. <init> : Replaced integer multiplication with division → KILLED
        sideA = (l * w);
29 1 1. <init> : Replaced integer multiplication with division → KILLED
        sideB = (w * h);
30 1 1. <init> : Replaced integer multiplication with division → KILLED
        sideC = (h * l);
31
    }
32
33
    /**
34
     * @param length of box.
35
     * @param width of box.
36
     * @param height of box.
37
     *
38
     * @return a {@link Day2} object based on a box with the specifications provided.
39
     */
40
    public static Day2 of(final int length,
41
                          final int width,
42
                          final int height) {
43 1 1. of : replaced return value with null for com/roxoft/aoc/y2015/Day2/Day2::of → KILLED
        return new Day2(length, width, height);
44
    }
45
46
    /**
47
     * @return surface area of the box.
48
     */
49
    public int getSurfaceArea() {
50 4 1. getSurfaceArea : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getSurfaceArea → KILLED
2. getSurfaceArea : Replaced integer multiplication with division → KILLED
3. getSurfaceArea : Replaced integer addition with subtraction → KILLED
4. getSurfaceArea : Replaced integer addition with subtraction → KILLED
        return 2 * (sideA + sideB + sideC);
51
    }
52
53
    /**
54
     * @return the required wrapping paper in square feet {@link #getSurfaceArea()} with "a little extra".
55
     */
56
    public int getRequiredWrappingPaper() {
57 2 1. getRequiredWrappingPaper : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredWrappingPaper → KILLED
2. getRequiredWrappingPaper : Replaced integer addition with subtraction → KILLED
        return getSurfaceArea() + Stream.of(sideA, sideB, sideC).min(Integer::compare).get();
58
    }
59
60
    /**
61
     * @return the amount of ribbon needed to wrap the present in feet.
62
     */
63
    public int getRequiredRibbonToWrap() {
64 1 1. getRequiredRibbonToWrap : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbonToWrap → KILLED
        return Stream.of(l, w, h)
65 1 1. lambda$getRequiredRibbonToWrap$0 : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::lambda$getRequiredRibbonToWrap$0 → KILLED
                .mapToInt(i -> i)
66
                .sorted()
67
                .limit(2)
68 1 1. getRequiredRibbonToWrap : Replaced integer multiplication with division → KILLED
                .sum() * 2;
69
    }
70
71
    /**
72
     * @return the amount of ribbon required to make a bow in feet.
73
     */
74
    public int getRequiredRibbonToMakeBow() {
75 3 1. getRequiredRibbonToMakeBow : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbonToMakeBow → KILLED
2. getRequiredRibbonToMakeBow : Replaced integer multiplication with division → KILLED
3. getRequiredRibbonToMakeBow : Replaced integer multiplication with division → KILLED
        return l * w * h;
76
    }
77
78
    /**
79
     * @return the required ribbon to wrap a present ({@link #getRequiredRibbonToWrap()}) and make a
80
     * bow ({@link #getRequiredRibbonToMakeBow()}).
81
     */
82
    public int getRequiredRibbon() {
83 2 1. getRequiredRibbon : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbon → KILLED
2. getRequiredRibbon : Replaced integer addition with subtraction → KILLED
        return getRequiredRibbonToWrap() + getRequiredRibbonToMakeBow();
84
    }
85
86
    @Override
87
    public boolean equals(final Object o) {
88 1 1. equals : negated conditional → KILLED
        if (this == o) {
89 1 1. equals : replaced boolean return with false for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED
            return true;
90
        }
91 2 1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
        if (o == null || getClass() != o.getClass()) {
92 1 1. equals : replaced boolean return with true for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED
            return false;
93
        }
94
        Day2 day2 = (Day2) o;
95 4 1. equals : negated conditional → KILLED
2. equals : replaced boolean return with true for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED
3. equals : negated conditional → KILLED
4. equals : negated conditional → KILLED
        return l == day2.l && w == day2.w && h == day2.h;
96
    }
97
98
    @Override
99
    public int hashCode() {
100 1 1. hashCode : replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::hashCode → KILLED
        return Objects.hash(l, w, h);
101
    }
102
}

Mutations

28

1.1
Location : <init>
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer multiplication with division → KILLED

29

1.1
Location : <init>
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer multiplication with division → KILLED

30

1.1
Location : <init>
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer multiplication with division → KILLED

43

1.1
Location : of
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToMakeBow()]
replaced return value with null for com/roxoft/aoc/y2015/Day2/Day2::of → KILLED

50

1.1
Location : getSurfaceArea
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getSurfaceArea → KILLED

2.2
Location : getSurfaceArea
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer multiplication with division → KILLED

3.3
Location : getSurfaceArea
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer addition with subtraction → KILLED

4.4
Location : getSurfaceArea
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_surfaceAreaCalculated()]
Replaced integer addition with subtraction → KILLED

57

1.1
Location : getRequiredWrappingPaper
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:example_A2()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredWrappingPaper → KILLED

2.2
Location : getRequiredWrappingPaper
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:example_A2()]
Replaced integer addition with subtraction → KILLED

64

1.1
Location : getRequiredRibbonToWrap
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToWrap()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbonToWrap → KILLED

65

1.1
Location : lambda$getRequiredRibbonToWrap$0
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToWrap()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::lambda$getRequiredRibbonToWrap$0 → KILLED

68

1.1
Location : getRequiredRibbonToWrap
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToWrap()]
Replaced integer multiplication with division → KILLED

75

1.1
Location : getRequiredRibbonToMakeBow
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToMakeBow()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbonToMakeBow → KILLED

2.2
Location : getRequiredRibbonToMakeBow
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToMakeBow()]
Replaced integer multiplication with division → KILLED

3.3
Location : getRequiredRibbonToMakeBow
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:requirement_ribbonToMakeBow()]
Replaced integer multiplication with division → KILLED

83

1.1
Location : getRequiredRibbon
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:example_B2()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::getRequiredRibbon → KILLED

2.2
Location : getRequiredRibbon
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:example_B2()]
Replaced integer addition with subtraction → KILLED

88

1.1
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

89

1.1
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
replaced boolean return with false for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED

91

1.1
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

92

1.1
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
replaced boolean return with true for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED

95

1.1
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
replaced boolean return with true for com/roxoft/aoc/y2015/Day2/Day2::equals → KILLED

3.3
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

4.4
Location : equals
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_equals()]
negated conditional → KILLED

100

1.1
Location : hashCode
Killed by : com.roxoft.aoc.y2015.Day2.Day2Test.[engine:junit-jupiter]/[class:com.roxoft.aoc.y2015.Day2.Day2Test]/[method:assumption_hashcode()]
replaced int return with 0 for com/roxoft/aoc/y2015/Day2/Day2::hashCode → KILLED

Active mutators

Tests examined


Report generated by PIT 1.14.4