View Single Post
  #7 (permalink)  
Old 07-06-2009, 6:58 PM
subaru_sti subaru_sti is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

Makes sense. The mod 32 is a good idea because if you pass in 360 (which is what I think you meant to write) you actually get 32 returned, which is not a value in the enum. That is better then the way I did it with adding the extra one.

For validation, I have this:

Code:
    Public Class Direction
        Private _course As Double

        Public Sub New(ByVal course As Double)
            Me.Course = course
        End Sub

        Public Property Course() As Double
            Get
                Return _course
            End Get
            Set(ByVal value As Double)
                If value > 360 Then Throw New ArgumentOutOfRangeException("Course cannot be greater than 360.")
                If value < 0 Then Throw New ArgumentOutOfRangeException("Course cannot be less than 0.")

                _course = value
            End Set
        End Property
    End Class
Thanks again,

Stephen
Reply With Quote