I have the following class definition
In the main code I access it as followsCode:Public Class Car Public ReadOnly MaxSpeed As Integer Private CurrSpeed As Integer Public Sub New() End Sub Public Sub New(ByVal max As Integer) MaxSpeed = 55 End Sub Public Property Speed() As Integer Get Return CurrSpeed End Get Set(ByVal value As Integer) CurrSpeed += value If CurrSpeed > MaxSpeed Then CurrSpeed = MaxSpeed End If End Set End Property End Class Public Class MiniVan Inherits Car End Class
When I run the Console App, I get the following output but I believe I should be getting - My van is going 10 mph.Code:Module Module1 Sub Main() Dim myCar As New Car(80) myCar.Speed = 50 Console.WriteLine("My car is going {0} MPH", myCar.Speed) Console.WriteLine() Dim myVan As New MiniVan() myVan.Speed = 10 Console.WriteLine("My van is going {0} MPH", myVan.Speed) Console.WriteLine() Console.ReadLine() End Sub End Module
My car is going 50 MPH
My van is going 0 MPH
Can somebody please explain, where I am going wrong?
Thanks
Edit/Delete Message




Reply With Quote