-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathErrorTrafficLightRGB.java
More file actions
54 lines (44 loc) · 1.17 KB
/
ErrorTrafficLightRGB.java
File metadata and controls
54 lines (44 loc) · 1.17 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// State Refinement Error
package testSuite;
import liquidjava.specification.Refinement;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@StateSet({"green", "amber", "red"})
public class ErrorTrafficLightRGB {
@Refinement("r >= 0 && r <= 255")
int r;
@Refinement("g >= 0 && g <= 255")
int g;
@Refinement("b >= 0 && b <= 255")
int b;
@StateRefinement(to = "green(this)")
public ErrorTrafficLightRGB() {
r = 255;
g = 0;
b = 0;
}
@StateRefinement(from = "green(this)", to = "amber(this)")
public void transitionToAmber() {
r = 255;
g = 120;
b = 0;
}
@StateRefinement(from = "red(this)", to = "green(this)")
public void transitionToGreen() {
r = 76;
g = 187;
b = 23;
}
@StateRefinement(from = "amber(this)", to = "red(this)")
public void transitionToRed() {
r = 230;
g = 0;
b = 1;
}
public static void name() {
ErrorTrafficLightRGB tl = new ErrorTrafficLightRGB();
tl.transitionToAmber();
tl.transitionToRed();
tl.transitionToAmber();
}
}