-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.java
43 lines (35 loc) · 1.02 KB
/
Calculator.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
38
39
40
41
42
43
import java.lang.System.*;
import java.lang.annotation.*;
import org.ow2.dsrg.jpmf.util.*;
import org.ow2.dsrg.jpmf.util.Configurator.*;
public class Calculator {
public static void main(String args[]) {
System.out.println("Hello, world!");
Calculator calc = new Calculator();
Configurator.setProperty(calc, "magic", "41");
Configurator.check(calc);
int result = calc.add(2,2);
System.out.println("The result is: "+result);
calc.printDefault();
}
public int add(int a, int b) {
return a + b + magic;
}
@Setter (name = "magic")
public void setOddMagic(String newMagic) {
int magicVal = Integer.parseInt(newMagic);
if (magicVal % 2 == 1) {
magic = magicVal;
System.out.println("Magic was odd");
} else {
System.out.println("Magic was NOT odd");
}
}
public void printDefault() {
System.out.println("The default value is: " + defaultInt);
}
@Property (name = "magic", required = true)
private Integer magic;
@Property (name = "default", defaultValue = "15")
private Integer defaultInt;
}