cfad47cfa3/t3compiler/tads3/test/data/cre_inst.t
| 4b825dc642cb6eb9a060e54bf8d69288fbee4904 | cfad47cfa334b206c65f22086bcc5d63e6f70944 | ||
|---|---|---|---|
1 | /* | ||
2 | * test of TadsObject.createInstance | ||
3 | */ | ||
4 | |||
5 | class Item: object | ||
6 | construct(x) | ||
7 | { | ||
8 | value = x; | ||
9 | } | ||
10 | generator(x) | ||
11 | { | ||
12 | return self.createInstance(x); | ||
13 | } | ||
14 | value = nil | ||
15 | ; | ||
16 | |||
17 | class BlueItem: Item | ||
18 | color = 'blue' | ||
19 | ; | ||
20 | |||
21 | class RedItem: Item | ||
22 | color = 'red' | ||
23 | ; | ||
24 | |||
25 | main(args) | ||
26 | { | ||
27 | local x; | ||
28 | |||
29 | x = RedItem.generator(1); | ||
30 | "red item color = <<x.color>>, value = <<x.value>>\n"; | ||
31 | |||
32 | x = BlueItem.generator(2); | ||
33 | "blue item color = <<x.color>>, value = <<x.value>>\n"; | ||
34 | } | ||
35 |
Download diff