private void btnStart_Click(object sender, EventArgs e) { txtBoxRace.Clear(); Turtle turtle = new Turtle("Turtle"); Liebre liebre = new Liebre("Rabbit"); race(turtle, liebre); }
private void ganador(int holderT, int holderL, Turtle turtle, Liebre liebre) { if (holderT > holderL) { txtBoxRace.Text += "GANADOR: " + turtle.name.ToUpper(); } else if (holderL < holderT) { txtBoxRace.Text += "GANADOR: " + liebre.name.ToUpper(); } else { txtBoxRace.Text += "EMPATE"; } }
private void race(Turtle turtle, Liebre liebre) { int holderTurtle = 0; int holderLiebre = 0; while (holderTurtle < 80 && holderLiebre < 80) { holderTurtle += turtle.pasos(); holderLiebre += liebre.pasos(); txtBoxRace.Text += turtle.name + " ha dado: " + holderTurtle + " pasos" + Environment.NewLine + liebre.name + " ha dado: " + holderLiebre + " pasos" + Environment.NewLine + "----------------------------------------" + Environment.NewLine; } ganador(holderTurtle, holderLiebre, turtle, liebre); }