|
Last change
on this file since 8153 was
8061,
checked in by bensch, 19 years ago
|
|
merged the scriptengine back to the trunk
|
|
File size:
665 bytes
|
| Rev | Line | |
|---|
| [8046] | 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() |
|---|
| [8058] | 29 | |
|---|
| 30 | return 2 |
|---|
| [8046] | 31 | --debug.debug() |
|---|
| 32 | end |
|---|
Note: See
TracBrowser
for help on using the repository browser.