paul@20 | 1 | public class ValueSubclass extends Value { |
paul@20 | 2 | |
paul@28 | 3 | /** |
paul@28 | 4 | * Test of subclass initialisation with super usage and foreign object initialisation. |
paul@28 | 5 | */ |
paul@20 | 6 | public ValueSubclass(int x) { |
paul@20 | 7 | super(x); |
paul@28 | 8 | Value tmp = new Value(42); |
paul@28 | 9 | } |
paul@28 | 10 | |
paul@28 | 11 | /** |
paul@28 | 12 | * Test of overriding. |
paul@28 | 13 | */ |
paul@28 | 14 | public void setValue(int x) { |
paul@28 | 15 | this.value = -x; |
paul@28 | 16 | } |
paul@28 | 17 | |
paul@28 | 18 | /** |
paul@28 | 19 | * Test of overriding and super methods. |
paul@28 | 20 | */ |
paul@28 | 21 | public int add(int x) { |
paul@28 | 22 | return super.add(-x); |
paul@28 | 23 | } |
paul@28 | 24 | |
paul@28 | 25 | /** |
paul@28 | 26 | * Test of objects as arguments. |
paul@28 | 27 | */ |
paul@28 | 28 | public void setValueObject(Value v) { |
paul@28 | 29 | this.value = v.getValue(); |
paul@20 | 30 | } |
paul@20 | 31 | } |