Public Class A 'Superclass
Private _W As Integer
Private _X As Integer
Public Sub New()
Console.WriteLine("This is Class A")
End Sub
Public Property W() As Integer
Get
Return _W
End Get
Set(value As Integer)
_W = value
End Set
End Property
Public Property X() As Integer
Get
Return _X
End Get
Set(value As Integer)
_X = value
End Set
End Property
Shared Sub Main()
Dim Object5 As New A
Dim Choice As Integer
Console.WriteLine("Please input W: ")
Object5.W = Console.ReadLine()
Console.WriteLine("Please input X: ")
Object5.X = Console.ReadLine()
Console.WriteLine("The product of W and X in Class A is: " &
Object5.Product(Object5.W, Object5.X))
Console.WriteLine("To show how an object calls another object")
Console.WriteLine("1. To run Class B")
Console.WriteLine("2. To run Class C")
Console.WriteLine()
Console.WriteLine("Please input a choice: ")
Console.WriteLine()
Choice = Console.ReadLine()
If Choice = 1 Then
B.Main1() ' Runs object based on Class B
Else
If Choice = 2 Then
C.Main1() ' Runs object based on Class C
Else
Console.WriteLine("Invalid Choice")
End If
End If
Console.ReadKey()
End Sub
Public Overridable Function Product(ByRef W1 As Integer, ByRef X1 As
Integer) As Integer
Return (X1 * W1)
End Function
End Class