' Fig. 9.14: Cylinder.vb
' CCylinder class inherits from class CCircle4.

Public Class CCylinder
    Inherits CCircle4

    Protected mHeight As Double

    ' default constructor
    Public Sub New()
        Height = 0
    End Sub ' New

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

        ' explicit call to CCircle4 constructor
        MyBase.New(xValue, yValue, radiusValue)
        Height = heightValue ' set CCylinder height
    End Sub ' New

    ' property Height
    Public Property Height() As Double

        Get
            Return mHeight
        End Get

        ' set CCylinder height if argument value is positive
        Set(ByVal heightValue As Double)
            : If heightValue >= 0 Then
                : mHeight = heightValue
                : End If

        End Set

    End Property ' Height

            ' override method Area to calculate CCylinder area
      Public Overrides Function Area() As Double
            : Return 2 * MyBase.Area + MyBase.Circumference * mHeight
      End Function ' Area

            ' calculate CCylinder volume
      Public Function Volume() As Double
            : Return MyBase.Area * mHeight
      End Function ' Volume

            ' convert CCylinder to String
      Public Overrides Function ToString() As String
            : Return MyBase.ToString() & "; Height = " & mHeight
      End Function ' ToString

   End Class ' CCylinder