Public Class Car
    Public Color As String
    Public HorsePower As Integer
    Private _speed As Integer
    Private _numberOfDoors As Integer

    ' Constructor...
    Sub New()

        ' set the defaults:
        Color = "White"
        _speed = 0
        _numberOfDoors = 5

    End Sub

    ' Speed - read-only property to return the speed...
    ReadOnly Property Speed() As Integer
        Get
            Return _speed
        End Get
    End Property

    ' Accelerate - add mph to the speed...
    Sub Accelerate(ByVal accelerateBy As Integer)

        ' adjust the speed...
        _speed += accelerateBy

    End Sub

    ' NumberOfDoors - get/set the number of doors...
    Property NumberOfDoors() As Integer

        ' called when the property is "got"...
        Get
            Return _numberOfDoors
        End Get

        ' called when the property is "set"...
        Set(ByVal Value As Integer)

            ' is the new value between two and five?
            If Value >= 2 And Value <= 5 Then
                _numberOfDoors = Value
            End If

        End Set

    End Property

    ' IsMoving - is the car moving?
    Public Function IsMoving() As Boolean

        ' is the car's speed zero?
        If Speed = 0 Then
            Return False
        Else
            Return True
        End If

    End Function

    ' CalculateAccelerationRate - assume a constant for a normal car...
    Overridable Function CalculateAccelerationRate() As Double

        ' if we assume a normal car goes from 0-60 in 14
        ' seconds, that's an average rate of 4.2 mph/s...
        Return 4.2

    End Function

End Class

