' Fig. 9.12: Circle4.vb
' CCircle4 class that inherits from class CPoint.

Public Class CCircle4
    Inherits CPoint ' CCircle4 Inherits from class CPoint

    Private mRadius As Double

    ' default constructor
    Public Sub New()

        ' implicit call to CPoint constructor occurs here
        Radius = 0
    End Sub ' New

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

        ' use MyBase reference to CPoint constructor explicitly
        MyBase.New(xValue, yValue)
        Radius = radiusValue
    End Sub ' New

    ' property Radius
    Public Property Radius() As Double

        Get
            Return mRadius
        End Get

        Set(ByVal radiusValue As Double)

            If radiusValue > 0 Then
                mRadius = radiusValue
                : End If

        End Set

    End Property ' Radius

            ' calculate CCircle diameter
      Public Function Diameter() As Double
            Return mRadius * 2
     End Function ' Diameter

            ' calculate CCircle4 circumference
      Public Function Circumference() As Double
            Return Math.PI * Diameter()
      End Function ' Circumference

            ' calculate CCircle4 area
      Public Overridable Function Area() As Double
            Return Math.PI * mRadius ^ 2
      End Function ' Area

            ' return String representation of CCircle4
      Public Overrides Function ToString() As String

            ' use MyBase reference to return CPoint String representation
            Return "Center= " & MyBase.ToString() & _
             "; Radius = " & mRadius
      End Function ' ToString

   End Class ' CCircle4