'Class Square module
Sub Class_Globals
Private mx, my, mWidth As Int
End Sub
'Initializes the object. You can add parameters to this method if needed.
Sub Initialize (Shapes As List, x As Int, y As Int, length As Int)
mx = x
my = y
mLength = length
Shapes.Add(Me)
End Sub
Sub Draw(c As Canvas)
Private r As Rect
r.Initialize(mx, my, mx + mLength, my + mLength)
c.DrawRect(r, Colors.Red, False, 1dip)
End Sub
'Class Circle module
Sub Class_Globals
Private mx, my, mRadius As Int
End Sub
'Initializes the object. You can add parameters to this method if needed.
Sub Initialize (Shapes As List, x As Int, y As Int, radius As Int)
mx = x
my = y
mRadius = radius
Shapes.Add(Me)
End Sub
Sub Draw(cvs As Canvas)
cvs.DrawCircle(mx, my, mRadius, Colors.Blue, False, 1dip)
End Sub
'Main Modul
Sub Process_Globals
Public Shapes As List
End Sub
Sub Globals
Private cvs As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
cvs.Initialize(Activity)
Private Square1, Square 2 As Square
Private Circle1 As Circle
Shapes.Initialize
Square1.Initialize(Shapes, 110dip, 110dip, 50dip)
Square2.Initialize(Shapes, 10dip, 10dip, 100dip)
Circle1.Initialize(Shapes, 50%x, 50%y, 100dip)
DrawAllShapes
End Sub
Sub DrawAllShapes
For i = 0 To Shapes.Size - 1
CallSub2(Shapes.Get(i), "Draw", cvs)
Next
Activity.Invalidate
End Sub