• Log in or sign up for an account here: https://www.sythe.org/login

Help with class

  • Thread starter Thread starter ludasky
  • Start date Start date
L

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
 
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.
 
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
 
Help with class
Some of the errors would be nice.
 
Runescape Gamblingrunescape gambling
Back
Top