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