<dependency>
<groupId>org.contract4j5</groupId>
<artifactId>contract4j5-annotations</artifactId>
<version>2.6.1</version>
</dependency>
public class Calculator {
public int divide(int x, int y) {
// Preconditions
if (y == 0) {
throw new IllegalArgumentException("Cannot divide by zero!");
}
// Postconditions
if ((x / y) * y != x) {
throw new RuntimeException("Incorrect division result!");
}
return x / y;
}
}