Last change
on this file since 8184 was
8061,
checked in by bensch, 18 years ago
|
merged the scriptengine back to the trunk
|
File size:
665 bytes
|
Line | |
---|
1 | function printf(...) io.write(string.format(unpack(arg))) end |
---|
2 | |
---|
3 | function Account:show() |
---|
4 | printf("Account balance = $%0.02f\n", self:balance()) |
---|
5 | end |
---|
6 | |
---|
7 | parent = {} |
---|
8 | |
---|
9 | function parent:rob(amount) |
---|
10 | amount = amount or self:balance() |
---|
11 | self:withdraw(amount) |
---|
12 | return amount |
---|
13 | end |
---|
14 | |
---|
15 | getmetatable(Account).__index = parent |
---|
16 | |
---|
17 | function main(arg) |
---|
18 | io.write("main received ", arg) |
---|
19 | io.write(" as parameter\n") |
---|
20 | Obj:printName() |
---|
21 | print('a =', a) |
---|
22 | print('b =', b) |
---|
23 | print('metatable =', getmetatable(a)) |
---|
24 | print('Account =', Account) |
---|
25 | table.foreach(Account, print) |
---|
26 | |
---|
27 | a:show() a:deposit(50.30) a:show() a:withdraw(25.10) a:show() |
---|
28 | Obj:printName() |
---|
29 | |
---|
30 | return 2 |
---|
31 | --debug.debug() |
---|
32 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.