Option Explicit On Option Strict On Public Class Person Public Sub New( _ ByVal firstName As String, _ ByVal lastName As String) Me.SetFirstName(firstName) Me.SetLastName(lastName) Me.SetCountryOfBirth(DEFAULT_COUNTRY_OF_BIRTH) End Sub Public Sub New( _ ByVal firstName As String, _ ByVal middleName As String, _ ByVal lastName As String, _ ByVal countryOfBirth As String) Me.SetFirstName(firstName) Me.SetMiddleName(middleName) Me.SetLastName(lastName) Me.SetCountryOfBirth(countryOfBirth) End Sub ' ' FirstName ' Private m_firstName As String = Nothing Public Function GetFirstName() As String If m_firstName Is Nothing Then Throw New Exception("firstName not set") End If Return m_firstName End Function Public Sub SetFirstName(ByVal firstName As String) If firstName Is Nothing Then Throw New ArgumentNullException( _ "firstName cannot be null") End If If firstName = "" Then Throw New ArgumentException( _ "firstName cannot be blank") End If m_firstName = firstName End Sub ' ' MiddleName ' Private m_middleName As String = Nothing Public Function GetMiddleName() As String If m_middleName Is Nothing Then Throw New Exception("middleName not set") End If Return m_middleName End Function Public Sub SetMiddleName(ByVal middleName As String) If middleName Is Nothing Then Throw New ArgumentNullException( _ "middleName cannot be null") End If If middleName = "" Then Throw New ArgumentException( _ "middleName cannot be blank") End If m_middleName = middleName End Sub Public Sub ClearMiddleName() m_middleName = Nothing End Sub Public Function HasMiddleName() As Boolean Return Not m_middleName Is Nothing End Function ' ' LastName ' Private m_lastName As String = Nothing Public Function GetLastName() As String If m_lastName Is Nothing Then Throw New Exception("lastName not set") End If Return m_lastName End Function Public Sub SetLastName(ByVal lastName As String) If lastName Is Nothing Then Throw New ArgumentNullException( _ "lastName cannot be null") End If If lastName = "" Then Throw New ArgumentException( _ "lastName cannot be blank") End If m_lastName = lastName End Sub ' ' CountryOfBirth ' Private Shared ReadOnly DEFAULT_COUNTRY_OF_BIRTH As String = "Thailand" Private m_countryOfBirth As String = Nothing Public Function GetCountryOfBirth() As String If m_countryOfBirth Is Nothing Then Throw New Exception("countryOfBirth not set") End If Return m_countryOfBirth End Function Public Sub SetCountryOfBirth(ByVal countryOfBirth As String) If countryOfBirth Is Nothing Then Throw New ArgumentNullException( _ "countryOfBirth cannot be null") End If If countryOfBirth = "" Then Throw New ArgumentException( _ "countryOfBirth cannot be blank") End If m_countryOfBirth = countryOfBirth End Sub End Class