private void SortareCls()
        {
            Jucator aux = new Jucator();

            for (int i = 0; i < 10; i++)
            {
                for (int j = i + 1; j < 11; j++)
                {
                    if (Convert.ToInt32(cls[i].Scor) < Convert.ToInt32(cls[j].Scor))
                    {
                        aux    = cls[i];
                        cls[i] = cls[j];
                        cls[j] = aux;
                    }
                    else if (Convert.ToInt32(cls[i].Scor) == Convert.ToInt32(cls[j].Scor))
                    {
                        if (cls[i].Nume == "-" && cls[j].Nume != "-")
                        {
                            aux    = cls[i];
                            cls[i] = cls[j];
                            cls[j] = aux;
                        }
                    }
                }
            }
        }
        public void AdaugaJ(Jucator x)
        {
            cls[10] = x;
            SortareCls();
            cls[10] = new Jucator("-", "0", "0");

            int i;

            //scriu clasamentl intr-un fisier
            StreamWriter cls_file = new StreamWriter(@"clasament_f.txt");

            for (i = 0; i < 10; i++)
            {
                cls_file.WriteLine(cls[i].Nume + "\t\t" + cls[i].Scor + "\t\t" + Jucator.vdif[Convert.ToInt32(cls[i].Dificultate)]);
            }
            cls_file.Close();
        }
Exemple #3
0
        private void timerDecrement_Tick(object sender, EventArgs e)
        {
            foreach (Label c in this.Controls.OfType <Label>())
            {
                if (Convert.ToString(c.Tag) == "timp")
                {
                    c.Text = Convert.ToString(Convert.ToInt32(c.Text) - 1);

                    if (Convert.ToInt32(c.Text) == 11)
                    {
                        c.ForeColor = Color.Yellow;
                    }
                    if (Convert.ToInt32(c.Text) == 7)
                    {
                        c.ForeColor = Color.Orange;
                    }
                    if (Convert.ToInt32(c.Text) == 4)
                    {
                        c.ForeColor = Color.OrangeRed;
                    }


                    if (c.Text == "0")
                    {
                        c.ForeColor            = Color.Red;
                        zero                   = true;
                        textBox1.Enabled       = false;
                        timerDecrement.Enabled = false;
                        Jucator x = new Jucator(nume, Convert.ToString(scor), Convert.ToString(dificultate));


                        Meniu.clasament.AdaugaJ(x);

                        scor = 0;
                    }
                }
            }
        }
        public Clasament()
        {
            int i;

            for (i = 0; i < 11; i++)
            {
                cls[i] = new Jucator("-", "0", "0");
            }


            String[] clas_f = File.ReadAllLines(@"clasament_f.txt");

            string[] line = new string[3];

            char[] separator = new char[] { '\t' };

            i = 0;

            foreach (string s in clas_f)
            {
                line = s.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                if (line[2] == "Mica")
                {
                    cls[i++] = new Jucator(line[0], line[1], "1");
                }
                else if (line[2] == "Medie")
                {
                    cls[i++] = new Jucator(line[0], line[1], "2");
                }
                else if (line[2] == "Mare")
                {
                    cls[i++] = new Jucator(line[0], line[1], "3");
                }
            }
        }