OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 class A { | 5 class A { |
6 final int x; | 6 final int x; |
7 final int y; | 7 final int y; |
8 A(this.y) : x = 42; | 8 A(this.y) : x = 42; |
9 method() { | 9 method() { |
10 print("A.method x: $x y: $y"); | 10 print("A.method x: $x y: $y"); |
11 print(this); | 11 print(this); |
12 print(this.runtimeType); | 12 print(this.runtimeType); |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 class B extends A { | 16 class B extends A { |
17 B(x) : super(x); | 17 B(x) : super(x); |
18 method() { | 18 method() { |
19 print("B.method x: $x y: $y"); | 19 print("B.method x: $x y: $y"); |
20 super.method(); | 20 super.method(); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 main() { | 24 main() { |
25 A a = new A(87); | 25 A a = new A(87); |
26 B b = new B(117); | 26 B b = new B(117); |
27 a.method(); | 27 a.method(); |
28 b.method(); | 28 b.method(); |
29 } | 29 } |
OLD | NEW |