Imports System
Public Class MainClass
Shared Sub Main()
Dim winArray(3) As Window
winArray(0) = New ListBox(1, 2, "First List Box")
winArray(1) = New ListBox(3, 4, "Second List Box")
winArray(2) = New Button(5, 6)
Dim i As Integer
For i = 0 To 2
winArray(i).DrawWindow( )
Next i
End Sub
End Class
MustInherit Public Class Window
Public Sub New(top As Integer, left As Integer)
Me.top = top
Me.left = left
End Sub 'New
Public MustOverride Sub DrawWindow( )
Protected top As Integer
Protected left As Integer
End Class 'Window
Public Class ListBox
Inherits Window
Public Sub New(top As Integer, left As Integer, contents As String)
MyBase.New(top, left) ' call base constructor
listBoxContents = contents
End Sub 'New
Public Overrides Sub DrawWindow( )
Console.WriteLine("Writing string to the listbox: {0}", listBoxContents)
End Sub 'DrawWindow
Private listBoxContents As String
End Class
Public Class Button
Inherits Window
Public Sub New(top As Integer, left As Integer)
MyBase.New(top, left)
End Sub
Public Overrides Sub DrawWindow( )
Console.WriteLine("Drawing a button at {0}, {1}" + ControlChars.Lf, top, left)
End Sub
End Class
|