Demonstrate an object with member object reference
Module Tester
Sub Main()
Dim employee As New CEmployee( _
"Bob", "Jones", 7, 24, 1949, 3, 12, 1988)
Console.WriteLine(employee.ToStandardString())
End Sub
End Module
Class CDay
Inherits Object
Private mMonth As Integer " 1-12
Private mDay As Integer " 1-31 based on month
Private mYear As Integer " any year
Public Sub New(ByVal monthValue As Integer, _
ByVal dayValue As Integer, ByVal yearValue As Integer)
mMonth = monthValue
mYear = yearValue
mDay = dayValue
End Sub
" create string containing month/day/year format
Public Function ToStandardString() As String
Return mMonth & "/" & mDay & "/" & mYear
End Function " ToStandardString
End Class
Class CEmployee
Inherits Object
Private mFirstName As String
Private mLastName As String
Private mBirthDate As CDay " member object reference
Private mHireDate As CDay " member object reference
Public Sub New(ByVal firstNameValue As String, _
ByVal lastNameValue As String, _
ByVal birthMonthValue As Integer, _
ByVal birthDayValue As Integer, _
ByVal birthYearValue As Integer, _
ByVal hireMonthValue As Integer, _
ByVal hireDayValue As Integer, _
ByVal hireYearValue As Integer)
mFirstName = firstNameValue
mLastName = lastNameValue
mBirthDate = New CDay(birthMonthValue, birthDayValue, _
birthYearValue)
mHireDate = New CDay(hireMonthValue, hireDayValue, _
hireYearValue)
End Sub " New
Public Function ToStandardString() As String
Return mLastName & ", " & mFirstName & " Hired: " _
& mHireDate.ToStandardString() & " Birthday: " & _
mBirthDate.ToStandardString()
End Function " ToStandardString
End Class
Jones, Bob Hired: 3/12/1988 Birthday: 7/24/1949