VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Kids"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa kids
Private kds As New Collection
Private Index As Integer
Private sex As String
Private sw As Swimmer
'-----
Public Sub add(sw As Swimmer)
  kds.add sw
End Sub
'-----
Public Sub setSex(sx As String)
  sex = sx
  moveFirst
End Sub
'-----
Public Sub moveFirst()
  Index = 1
  Set sw = kds(Index)
End Sub
'-----
Public Sub readKids(fname As String)
  Dim fl As New File
  fl.OpenForRead App.Path & "\" + fname
  'Wczytaj dane o zawodnikach
  While Not fl.fEof
    Set sw = New Swimmer
    sw.init fl
    add sw    'I przechowaj w odpowiednich obiektach
  Wend
  fl.closeFile
End Sub
'-----
'Zwraca true gdy istnieją jeszcze zawodnicy
'Danej płci
Public Function hasMoreElements() As Boolean
  Set sw = kds(Index)
  If sw.getSex = sex Or sex = "" Then
    hasMoreElements = Index < kds.Count
  Else
    nextElement
    hasMoreElements = Index < kds.Count
  End If
End Function
'-----
'Pobiera następnego zawodnika danej płci
Public Function nextElement() As Swimmer
  Set sw = kds(Index)
  If sex <> "" Then
    While sw.getSex <> sex And Index <= kds.Count
      Set sw = kds(Index)
      If sw.getSex <> sex Then Index = Index + 1
    Wend
    If sw.getSex = sex Then
      Set nextElement = sw
      Index = Index + 1
    Else
      Index = Index + 1
    End If
  Else
    Set nextElement = kds(Index)
    Index = Index + 1
  End If
End Function
