subaru_sti
Active member
- Joined
- Jul 4, 2009
- Messages
- 34
- Programming Experience
- Beginner
Hello.
I'm new to OOP and .Net and just need to make sure I am doing things correctly. Am I missing anything or are there better ways of doing this? Here is the first class I have written, for GSP coordinates.
Stephen
I'm new to OOP and .Net and just need to make sure I am doing things correctly. Am I missing anything or are there better ways of doing this? Here is the first class I have written, for GSP coordinates.
VB.NET:
Namespace GPS
Public Class Coordinate
Private _latitude As String
Private _longitude As String
Public Sub New(ByVal Latitude As Double, ByVal Longitude As Double)
MyBase.New()
Me.Latitude = Latitude
Me.Longitude = Longitude
End Sub
Public Property Latitude() As Double
Get
Return _latitude
End Get
Set(ByVal value As Double)
If value > 90 Then Throw New ArgumentOutOfRangeException("latitude", "Latitude cannot be greater than 90.")
If value < -90 Then Throw New ArgumentOutOfRangeException("latitude", "Latitude cannot be less than -90.")
_latitude = value
End Set
End Property
Public Property Longitude() As Double
Get
Return _longitude
End Get
Set(ByVal value As Double)
If value > 180 Then Throw New ArgumentOutOfRangeException("longitude", "Longitude cannot be greater than 180.")
If value < -180 Then Throw New ArgumentOutOfRangeException("longitude", "Longitude cannot be less than -180.")
_longitude = value
End Set
End Property
End Class
End Namespace
Stephen