//This method calculates the score and sets the value of the first object array public void finalScore(float[] array, float dificulty)//requires a float array and a float { if (array != null && diversIndex <= 19) { try { dificulty = float.Parse(levelOfDificultyTbox.Text); currentDiverNameLabel.Text = diverNameTBox.Text; currentDiverDDLabel.Text = dificulty.ToString("0.00"); } catch { finalScoreLabel.Text = "Error"; } Array.Sort(array); float finalScore = (array[2] + array[3] + array[4]) * dificulty; finalScoreLabel.Text = finalScore.ToString("0.00"); divers[0] = new Divescore(finalScore, diverNameTBox.Text, dificulty); } else { finalScoreLabel.Text = "Error"; } }
// This method populates the object array an set them to a default value public void populateObjetArray() { if ((divers[0]) == null) { Divescore tempObj = new Divescore(); for (int i = 0; i < divers.Length; i++) { divers[i] = tempObj; } } }
// This method compares diver objects by score. int IComparable.CompareTo(object o) { int returnVal; Divescore temp = (Divescore)o; if (Math.Abs(this.Score) > Math.Abs(temp.Score)) { returnVal = 1; } else { if (Math.Abs(this.Score) < Math.Abs(temp.Score)) { returnVal = -1; } else { returnVal = 0; } } return(returnVal); }