dc6f73e937db4b733a767f256a87e72227e12f24
[iot2.git] / iotjava / iotrmi / Java / sample / TestClass.java
1 package iotrmi.Java.sample;
2
3 import java.util.Set;
4
5 public class TestClass implements TestClassInterface {
6
7         /**
8          * Class Properties
9          */
10         private int intA;
11         private float floatB;
12         private String stringC;
13         private CallBackInterface cb;
14
15         /**
16          * Constructors
17          */
18         public TestClass() {
19
20                 intA = 1;
21                 floatB = 2;
22                 stringC = "345";
23                 cb = null;
24         }
25
26
27         public TestClass(int _int, float _float, String _string) {
28
29                 intA = _int;
30                 floatB = _float;
31                 stringC = _string;
32                 cb = null;
33         }
34
35
36         public void setA(int _int) {
37
38                 intA = _int;
39         }
40
41
42         public void setB(float _float) {
43
44                 floatB = _float;
45         }
46
47
48         public void setC(String _string) {
49
50                 stringC = _string;
51         }
52
53
54         // Getters
55         public String sumArray(String[] newA) {
56
57                 String sum = "";
58                 for (String i : newA) 
59                         sum = sum + i;
60                 return sum;
61         }
62
63
64         public int setAndGetA(int newA) {
65
66                 intA = newA;
67                 return intA;
68         }
69
70
71         public int setACAndGetA(String newC, int newA) {
72
73                 stringC = newC;
74                 intA = newA;
75                 return intA;
76         }
77
78
79         public void registerCallback(CallBackInterface _cb) {
80
81                 cb = _cb;
82         }
83
84
85         public int callBack() {
86
87                 return cb.printInt();
88         }
89
90
91         public static void main(String[] args) {
92
93                 TestClass tc = new TestClass();
94                 CallBack cb = new CallBack(3);
95
96                 tc.registerCallback(cb);
97                 System.out.println("Return value: " + tc.callBack());
98         }
99 }