50
50
Apr 21, 2011
While implementing factory pattern...you need runtime polymorphism.
Two classes implementing same interface having different implementation, deciding object to initialize at runtime
Interface iShape
Sub DrawShape()
End Interface
Public Class Circle
Implements iShape
Public Sub DrawShape() Implements iShape.DrawShape
Debug.WriteLine("this is drawing circle")
End Sub
End Class
Public Class Square
Implements iShape
Public Sub DrawShape() Implements iShape.DrawShape
Debug.WriteLine("this is drawing square")
End Sub
End Class
Somewhere in your application,
Sub main()
Dim s As iShape
s = New Circle
s.DrawShape()
s = New Square
s.DrawShape()
End Sub
Hope this helps.....
Saurin