Esempio n. 1
0
        /// <summary>
        /// Starts the race. The RunnerLaps Dictionary is populated with new values based on the Racers dictionary.
        /// </summary>
        public static void StartRace()
        {
            RunnerLaps.Clear();
            DateTime currentTime = DateTime.Now;

            foreach (int id in Runners.Keys)
            {
                RunnerLaps.Add(key: id, value: new List <DateTime>()
                {
                    currentTime
                });
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method checks how many entries are in the racer's RunnerLaps dictionary. Based on that, the number of laps he has finished is returned.
        /// Returns a "W" if given racer has already finished the race.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static object GetCurrentLap(int id)
        {
            if (Race.CheckFinishedRace(Race.Runners[id]))
            {
                return("W");
            }

            if (RunnerLaps.ContainsKey(id))
            {
                return(RunnerLaps[id].Count);
            }
            else
            {
                return(0);
            }
        }