Ejemplo n.º 1
0
        /// <summary>
        /// Create Racer with random still UNIQUEid
        /// </summary>
        /// <param name="name"></param>
        /// <param name="country"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        public void CreateRacer(string name, Country country, int age, string sex)
        {
            if (RacerMap.Keys.Count <= 999)
            {
                while (true)
                {
                    Id++;

                    if (!RacerMap.ContainsKey(Id))
                    {
                        break;
                    }

                    if (Id == 999)
                    {
                        Id = 0;
                    }
                }
                RacerMap[Id] = new Racer(Id, name, country, age, sex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metoda, ktora vrati pretekara s danym startovacim cislom
        /// </summary>
        /// <param name="startNumber">startovacie cislo pretekara</param>
        /// <returns>meno pretekara</returns>
        public string GetRacerNameByStartNumber(int startNumber, RacerRepository racerRepository)
        {
            Racer racer = racerRepository.GetRacerByStartNumber(startNumber);

            return(racer.Name);
        }
        /// <summary>
        /// Metoda, ktora vrati pretekara s danym indexom
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>pretekara s danym indexom</returns>
        public Racer GetRacerByIndex(int index)
        {
            Racer racer = Racers[index];

            return(racer);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Metoda, ktora vytvori pretekara
        /// </summary>
        /// <param name="startNumber">startovacie cislo</param>
        /// <param name="name">meno</param>
        /// <param name="age">vek</param>
        /// <param name="gender">pohlavie</param>
        /// <param name="Country">krajina</param>
        /// <returns>vytvoreneho pretekara</returns>
        public static Racer CreateRacer(int startNumber, string name, int age, Gender gender, string Country)
        {
            Racer racer = new Racer(startNumber, name, age, gender, Country);

            return(racer);
        }
        /// <summary>
        /// Metoda, ktora prida pretekara do zoznamu pretekarov
        /// </summary>
        /// <param name="startNumber">startovacie cislo</param>
        /// <param name="name">mano</param>
        /// <param name="age">vek</param>
        /// <param name="gender">pohlavie</param>
        /// <param name="country">krajina</param>
        public void Add(int startNumber, string name, int age, Gender gender, string country)
        {
            Racer racer = RacerFactory.CreateRacer(startNumber, name, age, gender, country);

            Racers.Add(racer);
        }