' Fig. 9.4: Point.vb
' CPoint class represents an x-y coordinate pair.

Public Class CPoint
    ' implicitly Inherits Object

    ' point coordinate
    Private mX, mY As Integer

    ' default constructor
    Public Sub New()

        ' implicit call to Object constructor occurs here
        X = 0
        Y = 0
    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
    End Sub ' New

    ' 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 CPoint
    Public Overrides Function ToString() As String
        Return "[" & mX & ", " & mY & "]"
    End Function ' ToString

End Class ' CPoint
