コード例 #1
0
        public void Uprav(string Jmeno, int Klub, int GolPocet, int index)
        {
            //hraciPole[index - 1].Jmeno = Jmeno;
            //hraciPole[index - 1].Klub = (Hrac.FotbalovyKlub)Klub;
            //hraciPole[index - 1].GolPocet = GolPocet;

            Hrac hracik = (Hrac)list[index - 1];

            hracik.Jmeno    = Jmeno;
            hracik.GolPocet = GolPocet;
            hracik.Klub     = (Hrac.FotbalovyKlub)Klub;
            list[index - 1] = hracik;
        }
コード例 #2
0
 private void Form2_Load(object sender, EventArgs e)
 {
     for (int i = 0; i < FotbalovyKlubInfo.Pocet; i++)
     {
         KlubComboBox.Items.Add(FotbalovyKlubInfo.DejNazev(i));
     }
     if (upravit)
     {
         Hrac hracik = (Hrac)list[index];
         JmenoTextBox.Text         = hracik.Jmeno;
         GolTextBox.Text           = Convert.ToString(hracik.GolPocet);
         KlubComboBox.SelectedText = FotbalovyKlubInfo.GetName((FotbalovyKlubInfo.FotbalovyKlub)hracik.Klub);
     }
 }
コード例 #3
0
        public static void Nacti(string fileName, LinkedList list)
        {
            string jmeno  = "";
            string klub   = "";
            string gol    = "";
            int    status = 0;

            lines = File.ReadAllLines(fileName).ToList();
            foreach (var line in lines)
            {
                jmeno  = "";
                klub   = "";
                gol    = "";
                status = 0;
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] != ',' && status == 0)
                    {
                        jmeno += line[i];
                    }
                    else if (status == 0)
                    {
                        status++;
                        i++;
                    }
                    if (line[i] != ',' && status == 1)
                    {
                        klub += line[i];
                    }
                    else if (status == 1)
                    {
                        i++;
                        status++;
                    }
                    if (line[i] != '\n' && status == 2)
                    {
                        gol += line[i];
                    }
                }
                Hrac hracik = new Hrac()
                {
                    Jmeno    = jmeno,
                    Klub     = (Hrac.FotbalovyKlub)Enum.Parse(typeof(FotbalovyKlubInfo.FotbalovyKlub), klub),
                    GolPocet = Int32.Parse(gol)
                };
                list.Add(hracik);
            }
        }
コード例 #4
0
        public void Pridej(string Jmeno, int Klub, int GolPocet)
        {
            Pocet++;
            onUpdatePocet();
            //hraciPole.Resize(Pocet);
            //hraciPole[hraciPole.Length() - 1] = new Hrac()
            //{
            //    Jmeno = Jmeno,
            //    Klub = (Hrac.FotbalovyKlub)Klub,
            //    GolPocet = GolPocet
            //};

            Hrac hrac = new Hrac()
            {
                Jmeno    = Jmeno,
                Klub     = (Hrac.FotbalovyKlub)Klub,
                GolPocet = GolPocet
            };

            list.Add(hrac);
        }
コード例 #5
0
        // string pole
        public void NjadiNejlepsiKluby(out string[] kluby, out int golPocet)
        {
            //kluby = new string[0];
            //List<string> stringList = new List<string>();
            //int max = 0;
            //int[] temp = new int[FotbalovyKlubInfo.Pocet];
            //for (int i = 0; i < hraciPole.Length(); i++)
            //{
            //    for (int j = 0; j < FotbalovyKlubInfo.Pocet; j++)
            //    {
            //        if (hraciPole[i].Klub == (Hrac.FotbalovyKlub)j)
            //            temp[j] += hraciPole[i].GolPocet;
            //    }
            //}
            //for (int i = 0; i < temp.Length; i++)
            //{
            //    if (temp[i] > max)
            //    {
            //        max = temp[i];
            //        stringList.Clear();
            //        stringList.Add(FotbalovyKlubInfo.DejNazev(i));
            //    }
            //    else if (temp[i] == max)
            //    {
            //        stringList.Add(FotbalovyKlubInfo.DejNazev(i));
            //    }

            //}
            //Array.Resize<string>(ref kluby, stringList.Count);
            //int y = 0;
            //foreach (var item in stringList)
            //{
            //    kluby[y] = item;
            //    y++;
            //}
            //golPocet = max;

            kluby = new string[0];
            List <string> stringList = new List <string>();
            int           max        = 0;

            int[] temp = new int[FotbalovyKlubInfo.Pocet];
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < FotbalovyKlubInfo.Pocet; j++)
                {
                    Hrac hracik = (Hrac)list[i];
                    if (hracik.Klub == (Hrac.FotbalovyKlub)j)
                    {
                        temp[j] += hracik.GolPocet;
                    }
                }
            }
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i] > max)
                {
                    max = temp[i];
                    stringList.Clear();
                    stringList.Add(FotbalovyKlubInfo.DejNazev(i));
                }
                else if (temp[i] == max)
                {
                    stringList.Add(FotbalovyKlubInfo.DejNazev(i));
                }
            }
            Array.Resize <string>(ref kluby, stringList.Count);
            int y = 0;

            foreach (var item in stringList)
            {
                kluby[y] = item;
                y++;
            }
            golPocet = max;
        }