| 1 | package io.github.some_example_name; | |
| 2 | ||
| 3 | /** | |
| 4 | * <code>GameTimerLogic</code> implements core countdown logic for the game timer. | |
| 5 | * <p> | |
| 6 | * Tracks and decrements time, no LibGDX dependencies for testing timer behaviour. | |
| 7 | * | |
| 8 | * @since 2025-11-04 | |
| 9 | */ | |
| 10 | public class GameTimerLogic { | |
| 11 | ||
| 12 | /** Time remaining in seconds */ | |
| 13 | private float timeLeft; | |
| 14 | ||
| 15 | /** | |
| 16 | * Constructs a new timer logic instance with the starting time. | |
| 17 | * | |
| 18 | * @param startSeconds initial time in seconds | |
| 19 | */ | |
| 20 | public GameTimerLogic(float startSeconds) { | |
| 21 | this.timeLeft = Math.max(0f, startSeconds); | |
| 22 | } | |
| 23 | ||
| 24 | /** | |
| 25 | * Decrements timer by the given value, stopping at zero. | |
| 26 | * | |
| 27 | * @param delta amount of time to subtract (seconds) | |
| 28 | */ | |
| 29 | public void decrement(float delta) { | |
| 30 |
2
1. decrement : changed conditional boundary → SURVIVED 2. decrement : negated conditional → KILLED |
if (delta <= 0f) { |
| 31 | return; | |
| 32 | } | |
| 33 | ||
| 34 |
1
1. decrement : Replaced float subtraction with addition → KILLED |
timeLeft -= delta; |
| 35 |
2
1. decrement : changed conditional boundary → SURVIVED 2. decrement : negated conditional → KILLED |
if (timeLeft < 0f) { |
| 36 | timeLeft = 0f; | |
| 37 | } | |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * Returns time remaining in seconds. | |
| 42 | * | |
| 43 | * @return time left in seconds | |
| 44 | */ | |
| 45 | public float getTimeLeft() { | |
| 46 |
1
1. getTimeLeft : replaced float return with 0.0f for io/github/some_example_name/GameTimerLogic::getTimeLeft → KILLED |
return timeLeft; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Shows whether the timer has reached zero. | |
| 51 | * | |
| 52 | * @return true if time has run out, false otherwise | |
| 53 | */ | |
| 54 | public boolean isTimeUp() { | |
| 55 |
3
1. isTimeUp : changed conditional boundary → KILLED 2. isTimeUp : negated conditional → KILLED 3. isTimeUp : replaced boolean return with true for io/github/some_example_name/GameTimerLogic::isTimeUp → KILLED |
return timeLeft <= 0f; |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Adds time to the timer (e.g. bonuses or penalties). | |
| 60 | * | |
| 61 | * @param seconds amount of time to add (can be negative) | |
| 62 | */ | |
| 63 | public void addTime(float seconds) { | |
| 64 |
1
1. addTime : Replaced float addition with subtraction → KILLED |
timeLeft += seconds; |
| 65 | ||
| 66 |
2
1. addTime : changed conditional boundary → SURVIVED 2. addTime : negated conditional → KILLED |
if (timeLeft < 0f) { |
| 67 | timeLeft = 0f; | |
| 68 | } | |
| 69 | } | |
| 70 | ||
| 71 | ||
| 72 | } | |
Mutations | ||
| 30 |
1.1 2.2 |
|
| 34 |
1.1 |
|
| 35 |
1.1 2.2 |
|
| 46 |
1.1 |
|
| 55 |
1.1 2.2 3.3 |
|
| 64 |
1.1 |
|
| 66 |
1.1 2.2 |