VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "AgeSwimData"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Implements SwimData
Private swimmers As Collection
Private Index As Integer
Private max As Integer, amax As Integer
Private ageList As Collection
Private Sex As String
 Public Sub setSex(sx As String)
 Sex = sx
 countAgeSex
 End Sub
Private Sub SwimData_Clone(swd As SwimData)

End Sub

Private Function SwimData_getNextSwimmer() As Swimmer
Set SwimData_getNextSwimmer = ageList(Index)
Index = Index + 1
End Function

Private Function SwimData_hasMoreElements() As Boolean
SwimData_hasMoreElements = Index <= amax
End Function

Private Sub SwimData_init(Filename As String)

End Sub

Private Sub SwimData_MoveFirst()
Index = 1
End Sub

Private Sub SwimData_setData(swcol As Collection)
Set swimmers = swcol
End Sub

Private Sub SwimData_sort()
Dim i As Integer, j As Integer
Dim sw As Swimmer, age As Integer
Dim ageString As String

max = swimmers.Count
ReDim sws(max) As Swimmer
For i = 1 To max
  Set sws(i) = swimmers(i)
Next i
For i = 1 To max
  For j = i To max
    If sws(i).getAge > sws(j).getAge Then
      Set sw = sws(i)
      Set sws(i) = sws(j)
      Set sws(j) = sw
    End If
  Next j
Next i
For i = max To 1 Step -1
  swimmers.Remove i
Next i
For i = 1 To max
  swimmers.Add sws(i)
Next i
countAgeSex
End Sub
Private Sub countAgeSex()
Dim i As Integer, j As Integer
Dim sw As Swimmer, age As Integer
Dim ageString As String

'Zlicz w każdej kategorii wiekowej
Set ageList = New Collection
age = swimmers(1).getAge
ageString = ""
i = 1
While i <= max
    If age = swimmers(i).getAge And Sex = swimmers(i).getSex Then
      ageString = ageString + "X"
    End If
    If age <> swimmers(i).getAge And Sex = swimmers(i).getSex Then
      Set sw = New Swimmer
      sw.setFirst Str$(age)
      sw.setLast ageString
      ageList.Add sw
      age = swimmers(i).getAge
      ageString = "X"
    End If
  i = i + 1
Wend
Set sw = New Swimmer
      sw.setFirst Str$(age)
      sw.setLast ageString
ageList.Add sw
amax = ageList.Count

End Sub
