mercredi 14 février 2018

Race results in a tie, How do I list both names on pedestal?

I am using visual studio C# to create a race result form to then display the winners on a pedestal in order for 1st, 2nd, and 3rd place. My code currently is set to display an error message if a tie occurs. I want to change it so that instead of an error message, the names will just be added to the corresponding pedestal so that ties are allowed.

Here is my code for my "tie" section.

// if the runners have a tie
            if (time1 == time2 || time2 == time3 || time3 == time1)
            {
                // show error message
                MessageBox.Show("It's a tie! Let's race again to find the real winner!");
                trophyGroupBox.Visible = false;
                timeBox1.Text = "";
                timeBox2.Text = "";
                timeBox3.Text = "";
                firstPlaceLabel.Text = "";
                secondPlaceLabel.Text = "";
                thirdPlaceLabel.Text = "";
                timeBox1.Focus();
                return;
            }

Part of my other code for when a tie does not occur and the names are listed as normal is...

  // if runner1 is faster than runner2
                if (time1 < time2)
                {
                    // display second and third place winners
                    secondPlaceLabel.Text = runner1;
                    silverTrophy.Text = runner1;
                    thirdPlaceLabel.Text = runner2;
                    bronzeTrophy.Text = runner2;
                }
                else
                {
                    // display second and third place winners
                    secondPlaceLabel.Text = runner2;
                    silverTrophy.Text = runner2;
                    thirdPlaceLabel.Text = runner1;
                    bronzeTrophy.Text = runner1;
                }

And here is what it looks like without a tie (and with a tie I simply want to just add a runner's name to the corresponding pedestal as a second name.

Race Results

Aucun commentaire:

Enregistrer un commentaire