1 | // TicketPriceCalculator.java | |
2 | package tpcalc; | |
3 | import java.util.List; | |
4 | ||
5 | public class TicketPriceCalculator { | |
6 | ||
7 | private static int ADULT_AGE = 18; | |
8 | private static int FREE_TICKET_AGE_BELOW = 3; | |
9 | public static double FAMILY_DISCOUNT = 0.05; | |
10 | ||
11 | public double calculatePrice(List<Passenger> passengers, int adultTicketPrice, int childTicketPrice) { | |
12 | int totalPrice = 0; | |
13 | int childrenCounter = 0; | |
14 | int adultCounter = 0; | |
15 | double result; | |
16 | for (Passenger passenger : passengers) { | |
17 |
2
1. calculatePrice : changed conditional boundary → KILLED 2. calculatePrice : negated conditional → KILLED |
if (passenger.getAge() > ADULT_AGE) { |
18 |
1
1. calculatePrice : Replaced integer addition with subtraction → KILLED |
totalPrice += adultTicketPrice; |
19 |
1
1. calculatePrice : Changed increment from 1 to -1 → KILLED |
adultCounter++; |
20 |
2
1. calculatePrice : changed conditional boundary → KILLED 2. calculatePrice : negated conditional → KILLED |
} else if (passenger.getAge() > FREE_TICKET_AGE_BELOW) { |
21 |
1
1. calculatePrice : Replaced integer addition with subtraction → KILLED |
totalPrice += childTicketPrice; |
22 |
1
1. calculatePrice : Changed increment from 1 to -1 → KILLED |
childrenCounter++; |
23 | } | |
24 | } | |
25 | ||
26 |
4
1. calculatePrice : changed conditional boundary → KILLED 2. calculatePrice : changed conditional boundary → KILLED 3. calculatePrice : negated conditional → KILLED 4. calculatePrice : negated conditional → KILLED |
if (childrenCounter > 1 && adultCounter > 1) { |
27 |
2
1. calculatePrice : Replaced double subtraction with addition → KILLED 2. calculatePrice : Replaced double multiplication with division → KILLED |
result = (1 - FAMILY_DISCOUNT) * totalPrice; |
28 | } else { | |
29 | result = totalPrice; | |
30 | } | |
31 | ||
32 |
1
1. calculatePrice : replaced return of double value with -(x + 1) for tpcalc/TicketPriceCalculator::calculatePrice → KILLED |
return result; |
33 | } | |
34 | } | |
Mutations | ||
17 |
1.1 2.2 |
|
18 |
1.1 |
|
19 |
1.1 |
|
20 |
1.1 2.2 |
|
21 |
1.1 |
|
22 |
1.1 |
|
26 |
1.1 2.2 3.3 4.4 |
|
27 |
1.1 2.2 |
|
32 |
1.1 |