shape.l (889B)
1 # 25jun07abu 2 # (c) Software Lab. Alexander Burger 3 4 # The Shape base class 5 (class +Shape) 6 # x y 7 8 (dm T (X Y) 9 (=: x X) 10 (=: y Y) ) 11 12 (dm move> (DX DY) 13 (inc (:: x) DX) 14 (inc (:: y) DY) ) 15 16 17 # The Rectangle class 18 (class +Rectangle +Shape) 19 # dx dy 20 21 (dm T (X Y DX DY) 22 (super X Y) 23 (=: dx DX) 24 (=: dy DY) ) 25 26 (dm area> () 27 (* (: dx) (: dy)) ) 28 29 (dm perimeter> () 30 (* 2 (+ (: dx) (: dy))) ) 31 32 (dm draw> () 33 (drawRect (: x) (: y) (: dx) (: dy)) ) # Hypothetical function 'drawRect' 34 35 36 # The Circle class 37 (class +Circle +Shape) 38 # r 39 40 (dm T (X Y R) 41 (super X Y) 42 (=: r R) ) 43 44 (dm area> () 45 (*/ (: r) (: r) 31415927 10000000) ) 46 47 (dm perimeter> () 48 (*/ 2 (: r) 31415927 10000000) ) 49 50 (dm draw> () 51 (drawCircle (: x) (: y) (: r)) ) # Hypothetical function 'drawCircle' 52 53 54 # The Fixed prefix class 55 (class +Fixed) 56 57 (dm move> (DX DY)) # A do-nothing method 58 59 # vi:et:ts=3:sw=3