-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBooleanAssertion.java
37 lines (31 loc) · 982 Bytes
/
BooleanAssertion.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 BooleanAssertion {
private boolean b; //Private field.
//Constructor
public BooleanAssertion(boolean b) {
this.b = b;
}
//Raises an exception if b != b2.
public BooleanAssertion isEqualTo(boolean b2) {
if(b != b2) {
throw new UnsupportedOperationException("BooleanAssertion.isEqualTo(boolean b2) raises exception.");
} else {
return this;
}
}
//Raises an exception if b is false.
public BooleanAssertion isTrue() {
if(b == false) {
throw new UnsupportedOperationException("BooleanAssertion.isTrue() raises exception.");
} else {
return this;
}
}
//Raises an exception if b is true.
public BooleanAssertion isFalse() {
if(b == true) {
throw new UnsupportedOperationException("BooleanAssertion.isFalse() raises exception.");
} else {
return this;
}
}
}