}//End btnClear //This button will calculate the dive score of the diver selected and the dive number selected private void btnDiveScore_Click(object sender, EventArgs e) { //Error check to make sure a diver is selected if (cmbDiverName.SelectedIndex == -1) { MessageBox.Show("Please make a dive name selection"); } else { //Error check to make sure a dive number was selected if (cmbDiveNumber.SelectedIndex == -1) { MessageBox.Show("Please make a dive number selection"); } else { //Check which diver number was selected if (cmbDiveNumber.Text == "1") { //set the DiveScore text to call the CalculateDive method from the diversClass with the dive number 1, and the index of the cmbDiverName txtDiveScore.Text = (divers.CalculateDive(1, cmbDiverName.SelectedIndex)).ToString(); } else if (cmbDiveNumber.Text == "2") { //set the DiveScore text to call the CalculateDive method from the diversClass with the dive number 2, and the index of the cmbDiverName txtDiveScore.Text = (divers.CalculateDive(2, cmbDiverName.SelectedIndex)).ToString(); } else { //set the DiveScore text to call the CalculateDive method from the diversClass with the dive number 3, and the index of the cmbDiverName txtDiveScore.Text = (divers.CalculateDive(3, cmbDiverName.SelectedIndex)).ToString(); } } } }//End btnDiveScore
static void Main(string[] args) { int numDivers = 0; string fileName = ""; fileName = Console.ReadLine(); DiverClass class1 = new DiverClass(fileName); class1.FillArray(fileName); class1.Sort(); class1.PrintArray(); numDivers = class1.CountDivers(); Console.WriteLine("There are " + numDivers + " divers."); Console.WriteLine(class1.CalculateDive(3, 21)); Console.WriteLine(class1.totalScore(20)); }