' Fig. 9.17: Circle5.vb
' CCircle5 class that inherits from class CPoint3.

Public Class CCircle5
    Inherits CPoint3 ' CCircle5 Inherits from class CPoint3

    Private mRadius As Double

    ' default constructor
    Public Sub New()

        ' implicit call to CPoint3 constructor occurs here
        Radius = 0
        Console.WriteLine("CCircle5 constructor: {0}", Me)
    End Sub ' New

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

        ' use MyBase reference to CPoint3 constructor explicitly
        MyBase.New(xValue, yValue)
        Radius = radiusValue
        Console.WriteLine("CCircle5 constructor: {0}", Me)
    End Sub ' New

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

    ' 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 CCircle5 diameter
    Public Function Diameter() As Double
        : Return mRadius * 2
    End Function ' Diameter

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

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

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

        ' use MyBase reference to return CPoint3 String
        : Return "Center = " & MyBase.ToString() & _
         "; Radius = " & mRadius
    End Function ' ToString
End Class ' CCircle5
