javaclass

tests/DispatchTest.java

130:e82008ab3e71
2005-01-14 Paul Boddie Added the mainloop method.
     1 public class DispatchTest {     2     public int a;     3     public float b;     4      5     public DispatchTest() {     6         this.a = 1;     7         this.b = 2;     8     }     9     10     public DispatchTest(int a) {    11         this.a = a;    12         this.b = 2;    13     }    14     15     public DispatchTest(float b) {    16         this.a = 1;    17         this.b = b;    18     }    19     20     public DispatchTest(int a, float b) {    21         this.a = a;    22         this.b = b;    23     }    24     25     public void set(int a) {    26         this.a = a;    27     }    28     29     public void set(float b) {    30         this.b = b;    31     }    32     33     // The ordering of the methods probably should not prevent the most specific    34     // method from being chosen, but this happens with a linear search of    35     // appropriate methods.    36     37     public int test(DispatchInterface obj) {    38         return obj.test();    39     }    40     41     public int test(DispatchClass1 obj) {    42         return obj.test() + 10;    43     }    44     45     public int testTest(DispatchInterface obj) {    46         return test(obj);    47     }    48 }    49     50 interface DispatchInterface {    51     public int test();    52 }    53     54 class DispatchClass1 implements DispatchInterface {    55     public int test() {    56         return 1;    57     }    58 }    59     60 class DispatchClass2 implements DispatchInterface {    61     public int test() {    62         return 2;    63     }    64 }