Imports System
Public Class MainClass
Shared Sub Main()
Dim f1 As New Fraction(3, 4)
Console.WriteLine("f1: {0}", f1.ToString( ))
Dim fa As New Fraction.FractionArtist( )
fa.Draw(f1)
End Sub
End Class
Public Class Fraction
Private numerator As Integer
Private denominator As Integer
Public Sub New( _
ByVal numerator As Integer, ByVal denominator As Integer)
Me.numerator = numerator
Me.denominator = denominator
End Sub 'New
Public Overrides Function ToString( ) As String
Return [String].Format("{0}/{1}", numerator, denominator)
End Function 'ToString
' Nested Class
Class FractionArtist
Public Sub Draw(ByVal f As Fraction)
Console.WriteLine("Drawing the numerator: {0}", f.numerator)
Console.WriteLine( _
"Drawing the denominator: {0}", f.denominator)
End Sub 'Draw
End Class 'FractionArtist
End Class 'Fraction
|