1 ---- Copyright 2012 Simon Dales
3 -- This work may be distributed and/or modified under the
4 -- conditions of the LaTeX Project Public License, either version 1.3
5 -- of
this license or (at your option) any later version.
6 -- The latest version of
this license is in
9 -- This work has the LPPL maintenance status `maintained
'.
11 -- The Current Maintainer of this work is Simon Dales.
16 \brief test some classes
22 --! \brief write to stdout
23 function TIO_write(Str)
29 --! \brief writeln to stdout
30 function TIO_writeln(Str)
38 --! \brief a base class
41 --! \brief constructor
42 function Animal.init(this)
43 this:setKind('animal
')
46 --! \brief set kind of object
47 function Animal.setKind(this,Kind)
51 --! \brief say the call of this animal
52 function Animal.call(this)
53 local speigel = this.speigel
55 speigel = ' says
"' .. speigel .. '"'
57 speigel = ' <undefined
call>
'
60 TIO_writeln(this.kind .. speigel)
63 --! \brief an abstract bird
66 --! \brief constructor
67 function Bird.init(this)
72 --! \brief a subclassed bird
75 --! \brief constructor
76 function Pigeon.init(this)
78 this:setKind('pigeon
')
79 this.speigel = 'oh my poor toe Betty
'
82 --! \brief another subclassed bird
85 --! \brief constructor
86 function RedKite.init(this)
88 this:setKind('red kite
')
89 this.speigel = 'weee-ooo ee oo ee oo ee oo
'
92 --! \brief a base mammal
93 Mammal = class(Animal)
95 --! \brief constructor
96 function Mammal.init(this)
100 --! \brief a subclassed mammal
103 --! \brief constructor
104 function Cat.init(this)
107 this.speigel = 'meow
'
110 --! \brief another subclassed mammal
113 --! \brief constructor
114 function Dog.init(this)
117 this.speigel = 'woof
'