Help with class

Discussion in 'Programming General' started by ludasky, Mar 28, 2008.

Help with class
  1. Unread #1 - Mar 28, 2008 at 5:05 AM
  2. ludasky
    Referrals:
    0

    ludasky Guest

    Help with class

    hi all,

    Im writing a geometric code using inheriting class. so far ive done this. I can code the radius entered by the user but i cant figure out how to code with the HEIGHT part for the volume of the cylinder. I cant use ByVal ??

    Option Explicit On
    Option Strict On

    Public Class Cylinder
    Inherits GeometricShape

    Private _radius As Decimal

    Sub New(ByVal theRadius As Decimal)
    Radius = theRadius
    MyBase.Volume = CalculationVolume()

    End Sub
    End Property
    Public Property Radius() As Decimal
    Get
    Return _radius


    End Get
    Set(ByVal value As Decimal)
    _radius = value

    End Set
    End Property

    Overrides Function CalculationVolume() As Decimal

    Return Convert.ToDecimal(Math.PI * Height * Radius * Radius)

    End Function
    End Class
     
  3. Unread #2 - Mar 28, 2008 at 5:24 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Help with class

    you haven't defined height _anywhere_. The only value you've defined is _radius. And you aren't even using that in the line where you refer to height.
     
  5. Unread #3 - Mar 28, 2008 at 5:40 AM
  6. ludasky
    Referrals:
    0

    ludasky Guest

    Help with class

    this is what ive done do far but still not working

    Option Explicit On
    Option Strict On

    Public Class Cylinder
    Inherits GeometricShape
    Private _height As Decimal
    Private _radius As Decimal

    Public Sub New(ByVal theRadius As Decimal, ByVal theHeight As Decimal)

    Height = theHeight
    Radius = theRadius
    MyBase.Volume = CalculationVolume()

    End Sub
    Public Property Height() As Decimal
    Get
    Return _height
    End Get
    Set(ByVal value As Decimal)
    _height = value

    End Set
    End Property
    Public Property Radius() As Decimal
    Get
    Return _radius


    End Get
    Set(ByVal value As Decimal)
    _radius = value

    End Set
    End Property


    Overrides Function CalculationVolume() As Decimal

    Return Convert.ToDecimal(Math.PI * Height * Radius * Radius)

    End Function
    End Class
     
  7. Unread #4 - Mar 28, 2008 at 7:17 AM
  8. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Help with class

    Some of the errors would be nice.
     
< Random Clicker | vb6 help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site