Sub Class_Globals
Private mName As String
Private mSalary As Double
Private mRegister As List
Private mRegistrar As clsPerson
Private mPassword As String
Private mMapByName As Map
End Sub
Public Sub Initialize(name As String, password As String)
mPassword = password
mName = name
mSalary = "NaN"
If password<>"" Then
mRegister.Initialize
mRegistrar = Me
mRegister.Add(Me)
mMapByName.Initialize
mMapByName.Put(mName, Me)
End If
End Sub
Public Sub Register(people As String)
Dim v() As String = Regex.Split(CRLF, people)
For Each s As String In v
Dim w() As String = Regex.Split(",", s)
If w.Length = 2 Then
Dim person As clsPerson
person.Initialize(w(0), "")
person.mSalary = w(1)
mRegister.Add(person)
person.mRegistrar = mRegistrar
mMapByName.Put(w(0), person)
End If
Next
End Sub
Public Sub AllPersons(password As String)
If password = mPassword And mRegister.isInitialized Then
For Each person As clsPerson In mRegister
Log(person.mName & TAB & person.mSalary)
Next
Else
Log("Access Denied")
End If
End Sub
Public Sub SalaryOf(name As String, password As String)
If password = mPassword And mRegister.isInitialized Then
Log(name & TAB & mMapByName.Get(name).As(clsPerson).mSalary)
Else
Log("Access Denied")
End If
End Sub
Public Sub getPerson(name As String, password As String) As clsPerson
If password = mPassword And mRegister.isInitialized Then
Return mMapByName.Get(name)
Else
Log("Access Denied")
Return Null
End If
End Sub
Public Sub Colleagues As List
Dim theList As List
theList.Initialize
For Each person As clsPerson In mRegistrar.mRegister
If person.mName <> mName Then theList.Add(person.mName)
Next
Return theList
End Sub