QuizLogic.java

1
package io.github.some_example_name;
2
3
/**
4
 * Pure logic for quiz behaviour.
5
 */
6
public class QuizLogic {
7
8
    public enum AnswerResult {
9
        CORRECT,
10
        INCORRECT,
11
        NONE
12
    }
13
14
    private boolean answered;
15
    private boolean correct;
16
    private boolean eventTriggered;
17
    private float waitTime;
18
19
    public QuizLogic(float waitTimeSeconds) {
20
        this.answered = false;
21
        this.correct = false;
22
        this.eventTriggered = false;
23
        this.waitTime = waitTimeSeconds;
24
    }
25
26
    /**
27
     * Processes an answer.
28
     * @param isCorrect whether the chosen answer is correct
29
     * @return result of the answer
30
     */
31
    public AnswerResult answer(boolean isCorrect) {
32 1 1. answer : negated conditional → KILLED
        if (answered) {
33 1 1. answer : replaced return value with null for io/github/some_example_name/QuizLogic::answer → KILLED
            return AnswerResult.NONE;
34
        }
35
36
        answered = true;
37
        correct = isCorrect;
38 2 1. answer : replaced return value with null for io/github/some_example_name/QuizLogic::answer → KILLED
2. answer : negated conditional → KILLED
        return correct ? AnswerResult.CORRECT : AnswerResult.INCORRECT;
39
    }
40
41
    /**
42
     * Updates timer after answering.
43
     * @param delta time step
44
     * @return true if quiz should exit
45
     */
46
    public boolean update(float delta) {
47 2 1. update : replaced boolean return with true for io/github/some_example_name/QuizLogic::update → KILLED
2. update : negated conditional → KILLED
        if (!answered) return false;
48
49 1 1. update : Replaced float subtraction with addition → KILLED
        waitTime -= delta;
50 3 1. update : changed conditional boundary → SURVIVED
2. update : replaced boolean return with true for io/github/some_example_name/QuizLogic::update → KILLED
3. update : negated conditional → KILLED
        return waitTime <= 0;
51
    }
52
53
    public boolean isAnswered() {
54 2 1. isAnswered : replaced boolean return with false for io/github/some_example_name/QuizLogic::isAnswered → KILLED
2. isAnswered : replaced boolean return with true for io/github/some_example_name/QuizLogic::isAnswered → KILLED
        return answered;
55
    }
56
57
    public boolean isCorrect() {
58 2 1. isCorrect : replaced boolean return with true for io/github/some_example_name/QuizLogic::isCorrect → KILLED
2. isCorrect : replaced boolean return with false for io/github/some_example_name/QuizLogic::isCorrect → KILLED
        return correct;
59
    }
60
61
    public boolean isEventTriggered() {
62 2 1. isEventTriggered : replaced boolean return with true for io/github/some_example_name/QuizLogic::isEventTriggered → KILLED
2. isEventTriggered : replaced boolean return with false for io/github/some_example_name/QuizLogic::isEventTriggered → KILLED
        return eventTriggered;
63
    }
64
65
    public void markEventTriggered() {
66
        this.eventTriggered = true;
67
    }
68
}

Mutations

32

1.1
Location : answer
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringIncorrectlyMarksQuizAnsweredAndIncorrect()]
negated conditional → KILLED

33

1.1
Location : answer
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringTwiceReturnsNoneSecondTime()]
replaced return value with null for io/github/some_example_name/QuizLogic::answer → KILLED

38

1.1
Location : answer
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringIncorrectlyMarksQuizAnsweredAndIncorrect()]
replaced return value with null for io/github/some_example_name/QuizLogic::answer → KILLED

2.2
Location : answer
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringIncorrectlyMarksQuizAnsweredAndIncorrect()]
negated conditional → KILLED

47

1.1
Location : update
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateBeforeAnswerDoesNothing()]
replaced boolean return with true for io/github/some_example_name/QuizLogic::update → KILLED

2.2
Location : update
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateBeforeAnswerDoesNothing()]
negated conditional → KILLED

49

1.1
Location : update
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateAfterAnswerCountsDownAndEventuallyExits()]
Replaced float subtraction with addition → KILLED

50

1.1
Location : update
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateAfterAnswerCountsDownAndEventuallyExits()]
replaced boolean return with true for io/github/some_example_name/QuizLogic::update → KILLED

2.2
Location : update
Killed by : none
changed conditional boundary → SURVIVED

3.3
Location : update
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateAfterAnswerCountsDownAndEventuallyExits()]
negated conditional → KILLED

54

1.1
Location : isAnswered
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringIncorrectlyMarksQuizAnsweredAndIncorrect()]
replaced boolean return with false for io/github/some_example_name/QuizLogic::isAnswered → KILLED

2.2
Location : isAnswered
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:updateBeforeAnswerDoesNothing()]
replaced boolean return with true for io/github/some_example_name/QuizLogic::isAnswered → KILLED

58

1.1
Location : isCorrect
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringIncorrectlyMarksQuizAnsweredAndIncorrect()]
replaced boolean return with true for io/github/some_example_name/QuizLogic::isCorrect → KILLED

2.2
Location : isCorrect
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:answeringCorrectlyMarksQuizAnsweredAndCorrect()]
replaced boolean return with false for io/github/some_example_name/QuizLogic::isCorrect → KILLED

62

1.1
Location : isEventTriggered
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:quizStartsUnanswered()]
replaced boolean return with true for io/github/some_example_name/QuizLogic::isEventTriggered → KILLED

2.2
Location : isEventTriggered
Killed by : io.github.some_example_name.QuizLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.QuizLogicTest]/[method:eventTriggeredFlagCanBeSet()]
replaced boolean return with false for io/github/some_example_name/QuizLogic::isEventTriggered → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0