Esempio n. 1
0
        /// <summary>
        /// Metoda, ktora zisti a refresne celkove vysledky
        /// </summary>
        public void RefreshResults()
        {
            Results.Clear();
            int highestFinishedRound = FinishedRounds.Max(x => x.FinishedRoundNumber);
            int ranking = 0;

            for (int i = highestFinishedRound; i > 0; i--)
            {
                List <Result> tempResults = new List <Result>();

                foreach (var finishedRound in FinishedRounds)
                {
                    bool isRacerInResults = HasRacerFinishedHigherRound(finishedRound);
                    if (finishedRound.FinishedRoundNumber == i && !isRacerInResults && finishedRound.FinishedRoundNumber <= RoundCount)
                    {
                        Result result = GetResult(finishedRound);
                        tempResults.Add(result);
                    }
                }

                List <Result> sortedList = tempResults.OrderBy(r => r.ResultTime).ToList();

                for (int j = 0; j < sortedList.Count; j++)
                {
                    sortedList[j].Ranking = ++ranking;
                    Results.Add(sortedList[j]);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Metoda, ktora vrati najvyssie/posledne odbehnute kolo pretekara s danym startovacim cislom
        /// </summary>
        /// <param name="startNumber">startovacie cislo</param>
        /// <returns></returns>
        public int GetHighestRacersFinishedRound(int startNumber)
        {
            int highestFinishedRound = 0;
            List <FinishedRound> finishedRoundsList      = FinishedRounds.ToList();
            List <FinishedRound> allFinishedRacersRounds = finishedRoundsList.FindAll(r => r.RacerNumber == startNumber);

            if (allFinishedRacersRounds.Count > 0)
            {
                highestFinishedRound = allFinishedRacersRounds.Max(r => r.FinishedRoundNumber);
            }

            return(highestFinishedRound);
        }
Esempio n. 3
0
        /// <summary>
        /// Metoda, ktora zaznamena odbehnute kolo
        /// </summary>
        /// <param name="racerNumber">startovacie cislo pretekara</param>
        public void RegisterFinishedRound(int racerNumber, RacerRepository racerRepository)
        {
            FinishedRound finishedRound = new FinishedRound();

            finishedRound.FinishedRoundTime = DateTime.Now;
            int lastFinishedRoundNumber = GetHighestRacersFinishedRound(racerNumber);

            finishedRound.FinishedRoundNumber = ++lastFinishedRoundNumber;
            finishedRound.RacerNumber         = racerNumber;
            finishedRound.RacerName           = GetRacerNameByStartNumber(racerNumber, racerRepository);
            finishedRound.RoundTime           = finishedRound.FinishedRoundTime - RaceStartTime;

            FinishedRounds.Add(finishedRound);
            RefreshResults();
        }
Esempio n. 4
0
 /// <summary>
 /// Store CurrentRound and create a new one.
 /// </summary>
 public void CreateNewRound()
 {
     FinishedRounds.Enqueue(CurrentRound);
     CurrentRound = new GrillRound(++_numberOfRounds, Length, Width);
 }