/// <summary> /// Removes the end scores as per official rules /// </summary> /// <returns>New list with the valid scores</returns> public ScoreList generateScoresWithoutFirstAndLastScore() { ScoreList ScoresWithoutFirstAndLastScore = new ScoreList(); SortScoreListAscending(); // sums all the scores // i start at 1 to skip first if (Scores?.Count > 2) { for (int i = 1; i < Scores.Count; i++) { // skip last if (i == Scores.Count - 1) { break; } ScoresWithoutFirstAndLastScore.Add(Scores[i]); } } else { return(Scores); } return(ScoresWithoutFirstAndLastScore); }
/// <summary> /// Gathers up the scores that have come in from the various judges /// However it will only create and store the ScoreList if all the scores have come in. /// </summary> public void CollectPoints() { bool AllPointsCollected = true; if (View.ListViewJudgeClients.Items.Count == CurrentContest.Judges.Count) { ScoreList scoreList = new ScoreList(); foreach (ListViewItem clientItem in View.ListViewJudgeClients.Items) { if (clientItem.SubItems[1].Text == "-1") { // One of the scores have not come in AllPointsCollected = false; break; } else { // Find the right Judge foreach (var judge in CurrentContest.Judges) { if (judge.GetFullName() == clientItem.SubItems[0].Text) { double score = double.Parse(clientItem.SubItems[1].Text); scoreList.Add(new Score(score, judge)); break; } } } } // All scores are in, go ahead and add the new ScoreList if (AllPointsCollected) { GetSelectedDive().Scores = scoreList; CancelModifyDive(); ResetPoints(); } else { MessageBox.Show("Väntar fortfarande på poäng från domare!"); } } else { MessageBox.Show("Alla domare måste ansuta först!"); } }
// Public Methods public void TestData() { ScoreList scoreList = new ScoreList(); scoreList.Add(new Score(2.5)); scoreList.Add(new Score(7.5)); scoreList.Add(new Score(3)); scoreList.Add(new Score(10)); scoreList.Add(new Score(5.5)); ScoreList scoreList2 = new ScoreList(); scoreList2.Add(new Score(2.5)); scoreList2.Add(new Score(3)); scoreList2.Add(new Score(2)); scoreList2.Add(new Score(8.5)); scoreList2.Add(new Score(5.5)); Dive dive = new Dive(new DiveCode(2.0, "10mbakåtvolt"), scoreList2); Dive dive2 = new Dive(new DiveCode(3.0, "10m"), scoreList); foreach (var sc in Model.SubContestBranches) { foreach (var c in sc.BranchContestants) { if (c.FirstName == "pelle") { sc.AddNewDive(c, dive2); } } } foreach (var sc in Model.SubContestBranches) { foreach (var c in sc.BranchContestants) { if (c.FirstName == "kalle") { sc.AddNewDive(c, dive); } } } }
/// <summary> /// /// </summary> /// <returns></returns> public double generateFinalizedScore() { double FinalizedScore = 0; ScoreList scoresWithoutFirstAndLastScore = generateScoresWithoutFirstAndLastScore(); //Summering av alla poäng if (scoresWithoutFirstAndLastScore != null) { foreach (var scores in scoresWithoutFirstAndLastScore) { FinalizedScore += scores.Value; } FinalizedScore *= Code.Multiplier; return(FinalizedScore); } return(-1); }
public Dive(DiveCode code, ScoreList scores, string name) { Code = code; Scores = scores; Name = name; }
public Dive(DiveCode code, ScoreList scores) { this.Code = code; this.Scores = scores; }
/// <summary> /// Adds the finalized ScoreList to this dive /// </summary> /// <param name="dive">The dive to be judged</param> /// <param name="scores">The list of points from the judges</param> public void AddFinalizedScoreListToDive(ScoreList scores) { this.Scores = scores; }