-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntAssertion.java
37 lines (31 loc) · 972 Bytes
/
IntAssertion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class IntAssertion {
private int i; //Private field.
//Constructor
public IntAssertion(int i) {
this.i = i;
}
//Raises an exception if i != i2.
public IntAssertion isEqualTo(int i2) {
if(i != i2) {
throw new UnsupportedOperationException("IntAssertion.isEqualTo(int i2) raises exception.");
} else {
return this;
}
}
//Raises an exception if i >= i2.
public IntAssertion isLessThan(int i2) {
if(i >= i2) {
throw new UnsupportedOperationException("IntAssertion.isLessThan(int i2) raises exception.");
} else {
return this;
}
}
//Raises an exception if i <= i2.
public IntAssertion isGreaterThan(int i2) {
if(i <= i2) {
throw new UnsupportedOperationException("IntAssertion.isGreaterThan(int i2) raises exception.");
} else {
return this;
}
}
}