Example #1
0
        private static void Nuskaityti()
        {
            using (var input = new StreamReader(KomanduDuomenuFailas)) {
                string[] temp;
                while ((temp = input.ReadLine()?.Split(';')) != null)
                {
                    switch (temp[0])
                    {
                    case "k":
                        KrepsinioKomandos[temp[1]] = new KrepsinioKomanda(
                            temp[1], temp[2], temp[3],
                            Convert.ToInt32(temp[4]));
                        break;

                    case "f":
                        FutboloKomandos[temp[1]] = new FutboloKomanda(
                            temp[1], temp[2], temp[3],
                            Convert.ToInt32(temp[4]));
                        break;

                    default:
                        throw new InvalidDataException("Duomenu failas netinkamas");
                    }
                }
            }

            using (var input = new StreamReader(ZaidejuDuomenuFailas)) {
                string[] temp;
                while ((temp = input.ReadLine()?.Split(';')) != null)
                {
                    Zaidejas zaidejas = null;
                    switch (temp[0])
                    {
                    case "k":
                        var k = new Krepsininkas(temp[3], temp[2],
                                                 Convert.ToInt32(temp[4]), Convert.ToInt32(temp[5]),
                                                 Convert.ToInt32(temp[6]), Convert.ToInt32(temp[7]), KrepsinioKomandos[temp[1]]);
                        KrepsinioKomandos[temp[1]].Zaidejai.Add(k);
                        zaidejas = k;
                        break;

                    case "f":
                        var f = new Futbolininkas(temp[3], temp[2],
                                                  Convert.ToInt32(temp[4]), Convert.ToInt32(temp[5]),
                                                  Convert.ToInt32(temp[6]), FutboloKomandos[temp[1]]);
                        FutboloKomandos[temp[1]].Zaidejai.Add(f);
                        zaidejas = f;
                        break;

                    default:
                        throw new InvalidDataException("Duomenu failas netinkamas");
                    }
                    VisiZaidejai.Add(zaidejas);
                }
            }
        }
 public void Add(Zaidejas z)
 {
     Zaidejai.Add(z);
 }