iNHERITANCE

Need help with this lab,
here is my code
i am getting this error message
when i use this piece of code

dim circle as new CCircle

Error      1      Argument not specified for parameter 'Rad_val' of 'Public Sub New(X_val As Integer, Y_val As Integer, Rad_val As Integer)'.      

Error      2      Argument not specified for parameter 'X_val' of 'Public Sub New(X_val As Integer, Y_val As Integer, Rad_val As Integer)'.

Error      3      Argument not specified for parameter 'Y_val' of 'Public Sub New(X_val As Integer, Y_val As Integer, Rad_val As Integer)'.

I am new in this oop . any help will be appreciated.
my teacher told me  to test both clasess.
what changes Do I need to make in order to make this lab to work...
thanks



'Create a class called CPoint that includes the following:
Public Class CPoint
#Region "Instance Variables"
    '"    Private integers mX and mY
    Private_X As Integer
   Private _Y As Integer
#End Region
 
#Region "Constructors"
    '    A default constructor that sets mX and mY to zero
    Public Sub New()
        _X = 0
        _Y = 0
    End Sub
    '"    A constructor that allows input for mX and mY
    Public Sub New(ByVal X_value As Integer, _
         ByVal Y_value As Integer)
 
        _X = X_value
        _Y = Y_value
    End Sub
#End Region
 
#Region "Properties"
    '    Public properties X   that returns mX
    Public Property X() As Integer
        Get
            Return _X
        End Get
 
        Set(ByVal Value As Integer)
            _X = Value
        End Set
    End Property
    'Public properties Y  that returns mY
    Public Property Y() As Integer
        Get
            Return _Y
        End Get
 
        Set(ByVal Value As Integer)
            _Y = Value
        End Set
    End Property
    'A Public Overridable ReadOnly Property Area that return 0 as a double
    Public ReadOnly Property Area() As Double
        Get
            Return 0
        End Get
    End Property
    '"    A Public ReadOnly Property Diameter that returns 0 as a double
    Public ReadOnly Property Diameter() As Double
        Get
            Return 0
        End Get
    End Property
 
#End Region
 
 
 
End Class
 
  this is the child class
 
'Create a class called CCircle that inherits CPoint that includes the following
Public Class CCircle
    Inherits CPoint
 
#Region "Instance Variables"
    '    Private double mRadius
    Private _Radius As Double
    Private _Area As Double
    Private _Circunference As Double
    Private _Diameter As Double
#End Region
 
#Region "Constructors"
    '    A constructor that accepts an X, Y and radius Value
    Public Sub New(ByVal X_val As Integer, ByVal Y_val As Integer, _
         ByVal Rad_val As Integer)
        X_val = _X
        Rad_val = _Radius
        Y_val = _Y
    End Sub
#End Region
 
 
 
#Region "Properties"
    '    A Radius Property
    Public Property Radius() As Double
        Get
            Return _Radius
        End Get
 
        Set(ByVal Value As Double)
            _Radius = Value
        End Set
    End Property
 
    '    Create Area, Circumference and Diameter Properties
 
    Public Overloads Property Area() As Double
        Get
            Return _Area
        End Get
 
        Set(ByVal Value As Double)
            _Area = Value
        End Set
    End Property
 
 
    Public Property circunference() As Double
        Get
            Return _Circunference
        End Get
 
        Set(ByVal Value As Double)
            _Circunference = Value
        End Set
    End Property
    Public Overloads Property Diameter() As Double
        Get
            Return _Diameter
        End Get
        Set(ByVal value As Double)
            _Diameter = value
        End Set
    End Property
#End Region
    '    Ovveride the ToString Function to return something that looks like Center = [10, 10]; Radius = 20
 
 
#Region "Functions"
    Public Function CalculateDiameter() As Double
        Return Radius * 2
    End Function
 
    Public Function CalculateCircmuference() As Double
        Return CalculateDiameter() * Math.PI
    End Function
 
    Public Function CalculateArea() As Double
        Return Radius * Radius * Math.PI
    End Function
#End Region
 
 
 
 
 
 
    Public Overrides Function ToString() As String
        Return Convert.ToString(X) & ", " & Convert.ToString(Y) & _
         vbNewLine & "Radius = " & _Radius
    End Function
End Class

Open in new window

OCUAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inthecurveCommented:
In the constructor of CCircle, the _X and _Y variables are not accessible in this context because they are 'Private'.  That's the only issue with this code.  Their scope would need to be 'Protected Friend'.
0
jindalankushCommented:
i think,
you have not defined constructor without argument.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
inthecurveCommented:
dim circle as new CCircle() should be fine as there is a default constructor which requires no parameters:
Public Sub New()
        _X = 0
        _Y = 0
End Sub
Public Sub New(ByVal X_value As Integer, _
         ByVal Y_value As Integer)
 
        _X = X_value
        _Y = Y_value
End Sub

The errors seems to be coming from the issue that I noted regarding the scope of the variables _X and _Y.
0
inthecurveCommented:
My mistake, jindalankush is correct and not me.  I overlooked the constructor in the CCircle class.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.