VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Employee"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa Employees
'Prosta implementacja AbstractEmployee
'Umożliwiająca przechowanie informacji o podwładnych
Implements AbstractEmployee
Private empName As String
Private salary As Single
Private subordinates As Subords 'Lista podwładnych
'--------
Private Sub AbstractEmployee_add(nm As String, salary As Single)
  Dim newEmp As AbstractEmployee
  Set newEmp = New Employee
  newEmp.init nm, salary
  subordinates.add newEmp
End Sub
'--------
Private Sub AbstractEmployee_addEmp(emp As AbstractEmployee)
  subordinates.add emp
End Sub
'--------
Private Function AbstractEmployee_getChild(nm As String) As AbstractEmployee
  Dim found As Boolean, tEmp As AbstractEmployee
  If empName = nm Then
    Set AbstractEmployee_getChild = Me
  Else
    found = False
    subordinates.moveFirst
    While Not found And subordinates.hasMoreElements
      If subordinates.hasMoreElements Then
        Set tEmp = subordinates.nextElement
        found = (tEmp.getName = nm)
        If Not found Then
          If Not tEmp.isLeaf Then
            Set tEmp = tEmp.getChild(nm)
            found = (tEmp.getName = nm)
          End If
        End If
      End If
    Wend
    If found Then
      Set AbstractEmployee_getChild = tEmp
    Else
      Set AbstractEmployee_getChild = New Employee
    End If
  End If
End Function
'--------
Private Function AbstractEmployee_getName() As String
  AbstractEmployee_getName = empName
End Function
'--------
Private Function AbstractEmployee_getSalaries() As Single
  Dim sum As Single, esub As AbstractEmployee
  'Pobierz sumę zarobków pracownika i jego podwładnych
  sum = salary
  subordinates.moveFirst
  While subordinates.hasMoreElements
    Set esub = subordinates.nextElement
    sum = sum + esub.getSalaries
  Wend
  AbstractEmployee_getSalaries = sum
End Function
'--------
Private Function AbstractEmployee_getSalary() As Single
  AbstractEmployee_getSalary = salary
End Function
'--------
Private Function AbstractEmployee_getSubordinates() As Subords
  Set AbstractEmployee_getSubordinates = subordinates
End Function
'--------
Private Sub AbstractEmployee_init(name As String, salry As Single)
  empName = name
  salary = salry
  Set subordinates = New Subords
End Sub
'--------
Private Function AbstractEmployee_isLeaf() As Boolean
  AbstractEmployee_isLeaf = False
End Function
'--------
Private Sub AbstractEmployee_remove(emp As AbstractEmployee)

End Sub
