' Fig. 9.16: Point3.vb
' CPoint3 class represents an x-y coordinate pair.

Public Class CPoint3

    ' point coordinate
    Private mX, mY As Integer

    ' default constructor
    Public Sub New()

        ' implicit call to Object constructor occurs here
        X = 0
        Y = 0
        Console.Writeline("CPoint3 constructor: {0}", Me)
    End Sub ' New

    ' constructor
    Public Sub New(ByVal xValue As Integer, _
            ByVal yValue As Integer)

        ' implicit call to Object constructor occurs here
        X = xValue
        Y = yValue
        Console.Writeline("CPoint3 constructor: {0}", Me)
    End Sub ' New

    ' finalizer overrides version in class Object
    Protected Overrides Sub Finalize()
        Console.Writeline("CPoint3 Finalizer: {0}", Me)
        MyBase.Finalize() ' call Object finalizer
    End Sub ' Finalize

    ' property X
    Public Property X() As Integer

        Get
            Return mX
        End Get

        Set(ByVal xValue As Integer)
            mX = xValue ' no need for validation
        End Set

    End Property ' X

    ' property Y 
    Public Property Y() As Integer

        Get
            Return mY
        End Get

        Set(ByVal yValue As Integer)
            mY = yValue ' no need for validation
        End Set

    End Property ' Y

    ' return String representation of CPoint3
    Public Overrides Function ToString() As String
        Return "[" & mX & ", " & mY & "]"
    End Function ' ToString

End Class ' CPoint3
