Пример #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            txtResult.Clear();

            Corredor c1 = new Corredor();
            Corredor c2 = new Corredor();

            txtResult.Text += "c1 = " + c1.distancia.ToString() + "\t c2 = " + c2.distancia.ToString() + Environment.NewLine;

            while (c1.distancia < 100 && c2.distancia < 100)
            {
                c1.Correr();
                c2.Correr();
                txtResult.Text += "c1 = " + c1.distancia.ToString() + "\t c2 = " + c2.distancia.ToString() + Environment.NewLine;
            }

            if (c1.distancia >= 100 && c2.distancia >= 100)
            {
                txtResult.Text += "¡¡¡ES UN EMPATE!!!";
            }
            else if (c1.distancia >= 100)
            {
                txtResult.Text += "¡¡¡GANA c1!!!";
            }
            else
            {
                txtResult.Text += "¡¡¡GANA c2!!!";
            }
        }
Пример #2
0
        private string Carreritas(Corredor c1, Corredor c2)
        {
            string res = "";

            while (c1.Pasos < 100 && c2.Pasos < 100)
            {
                c1.Pasos += c1.Correr();
                c2.Pasos += c2.Correr();
                res      += c1.Nombre + " esta en: " + c1.Pasos + Environment.NewLine +
                            c2.Nombre + " esta en: " + c2.Pasos + Environment.NewLine;
            }
            if (c1.Pasos >= 100 && c2.Pasos >= 100)
            {
                res += "EMPATE";
            }
            else if (c1.Pasos < c2.Pasos)
            {
                res += "EL GANADOR ES: " + c2.Nombre;
            }
            else
            {
                res += "EL GANADOR ES: " + c1.Nombre;
            }
            return(res);
        }