Imports System.Collections

Public Class Kids
  Implements IEnumerable
  Private kidList As ArrayList
  Private index As Short
  Public Sub New(ByRef Filename As String)
    MyBase.New()
    Dim sline As String           'Wiersz wczytany z pliku
    Dim vbf As vbFile = New vbFile(Filename) 'Instancja klasy vbFile
    Dim kd As Kid
    kidList = New ArrayList()
    vbf.OpenForRead()             'Otwórz plik
    sline = vbf.readLine
    While sline.Length > 0        'Wczytaj wiersze
      kd = New Kid(sline)         'Umieść dane w instancji klasy Kid
      kidList.Add(kd)             'Dodaj do kolekcji
      sline = vbf.readLine
    End While
    vbf.closeFile()
  End Sub

  Public Function getIterator() As IEnumerator
    Dim kiter As KidIterator = New KidIterator(kidList) ' Utwórz iterator
    Return kiter                  'I zwróć go
  End Function

  Public Function getClubIterator(ByRef clb As String) As IEnumerator
    Dim kiter As KidClubIterator = New KidClubIterator(kidList, clb) ' Utwórz iterator
    Return kiter                  'I zwróć go
  End Function

  Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
    Return getIterator()
  End Function
End Class
