1 | package com.example; | |
2 | ||
3 | public class Calculator { | |
4 | public int add(int a, int b) { | |
5 |
2
1. add : Replaced integer addition with subtraction → KILLED 2. add : replaced int return with 0 for com/example/Calculator::add → KILLED |
return a + b; |
6 | } | |
7 | ||
8 | public int subtract(int a, int b) { | |
9 |
2
1. subtract : Replaced integer subtraction with addition → KILLED 2. subtract : replaced int return with 0 for com/example/Calculator::subtract → KILLED |
return a - b; |
10 | } | |
11 | ||
12 | public int multiply(int a, int b) { | |
13 |
2
1. multiply : Replaced integer multiplication with division → KILLED 2. multiply : replaced int return with 0 for com/example/Calculator::multiply → KILLED |
return a * b; |
14 | } | |
15 | ||
16 | public int divide(int a, int b) { | |
17 |
1
1. divide : negated conditional → KILLED |
if (b == 0) { |
18 | throw new IllegalArgumentException("Cannot divide by zero!"); | |
19 | } | |
20 |
2
1. divide : Replaced integer division with multiplication → KILLED 2. divide : replaced int return with 0 for com/example/Calculator::divide → KILLED |
return a / b; |
21 | } | |
22 | } | |
Mutations | ||
5 |
1.1 2.2 |
|
9 |
1.1 2.2 |
|
13 |
1.1 2.2 |
|
17 |
1.1 |
|
20 |
1.1 2.2 |