paul@28 | 1 | public class DispatchTest { |
paul@28 | 2 | public int a; |
paul@28 | 3 | public float b; |
paul@28 | 4 | |
paul@28 | 5 | public DispatchTest() { |
paul@28 | 6 | this.a = 1; |
paul@28 | 7 | this.b = 2; |
paul@28 | 8 | } |
paul@28 | 9 | |
paul@28 | 10 | public DispatchTest(int a) { |
paul@28 | 11 | this.a = a; |
paul@28 | 12 | this.b = 2; |
paul@28 | 13 | } |
paul@28 | 14 | |
paul@28 | 15 | public DispatchTest(float b) { |
paul@28 | 16 | this.a = 1; |
paul@28 | 17 | this.b = b; |
paul@28 | 18 | } |
paul@28 | 19 | |
paul@28 | 20 | public DispatchTest(int a, float b) { |
paul@28 | 21 | this.a = a; |
paul@28 | 22 | this.b = b; |
paul@28 | 23 | } |
paul@28 | 24 | |
paul@28 | 25 | public void set(int a) { |
paul@28 | 26 | this.a = a; |
paul@28 | 27 | } |
paul@28 | 28 | |
paul@28 | 29 | public void set(float b) { |
paul@28 | 30 | this.b = b; |
paul@28 | 31 | } |
paul@32 | 32 | |
paul@32 | 33 | public int test(DispatchInterface obj) { |
paul@32 | 34 | return obj.test(); |
paul@32 | 35 | } |
paul@32 | 36 | |
paul@32 | 37 | public int test(DispatchClass1 obj) { |
paul@32 | 38 | return obj.test(); |
paul@32 | 39 | } |
paul@32 | 40 | |
paul@32 | 41 | public int testTest(DispatchInterface obj) { |
paul@32 | 42 | return test(obj); |
paul@32 | 43 | } |
paul@28 | 44 | } |
paul@32 | 45 | |
paul@32 | 46 | interface DispatchInterface { |
paul@32 | 47 | public int test(); |
paul@32 | 48 | } |
paul@32 | 49 | |
paul@32 | 50 | class DispatchClass1 implements DispatchInterface { |
paul@32 | 51 | public int test() { |
paul@32 | 52 | return 1; |
paul@32 | 53 | } |
paul@32 | 54 | } |
paul@32 | 55 | |
paul@32 | 56 | class DispatchClass2 implements DispatchInterface { |
paul@32 | 57 | public int test() { |
paul@32 | 58 | return 2; |
paul@32 | 59 | } |
paul@32 | 60 | } |