Ejemplo n.º 1
0
        public override float GenerateScore(Registration registration)
        {
            if (registration.IsDisqualified())
                return 0;

            Dictionary<string, int> scores = registration.GetAllScores();
            int minimumScore = int.MaxValue;
            int maximumScore = -1;
            int totalScore = 0;

            foreach(KeyValuePair<string, int> score in scores)
            {
                totalScore += score.Value;
                if (score.Value < minimumScore)
                    minimumScore = score.Value;
                if (score.Value > maximumScore)
                    maximumScore = score.Value;
            }

            if (scores.Count <= 2)
                return totalScore / scores.Count;

            totalScore -= minimumScore;
            totalScore -= maximumScore;

            return Convert.ToSingle(totalScore)/(Convert.ToSingle(scores.Count) - 2f);
        }
Ejemplo n.º 2
0
        public override float GenerateScore(Registration registration)
        {
            if (registration.IsDisqualified())
                return 0;

            int totalScore = 0;
            Dictionary<string, int> scores = registration.GetAllScores();
            foreach (KeyValuePair<string, int> score in scores)
                totalScore += score.Value;

            return Convert.ToSingle(totalScore) / Convert.ToSingle(scores.Count);
        }
        /// <summary>
        /// Funkcija koja generira prijave
        /// </summary>
        /// <param name="listOfCompetitors">Lista natjecatelja</param>
        /// <param name="maxThemeNumberPerCompetitor">Maksimalni broj tema po natjecatelju</param>
        /// <param name="maxCategoryNumberPerCompetitor">Maksimalni broj kategorija po natjecatelju</param>
        /// <param name="numberOfThemes">Broj tema</param>
        /// <param name="listOfThemes">Lista tema</param>
        /// <param name="numberOfCategories">Broj kategorija</param>
        /// <param name="listOfCategories">Lista odabranih kategorija</param>
        /// <returns>Lista generiranih prijava</returns>
        private List<Registration> GenerateRegistrations(List<Competitor> listOfCompetitors, int maxThemeNumberPerCompetitor, int maxCategoryNumberPerCompetitor, int numberOfThemes, List<Theme> listOfThemes, int numberOfCategories, List<string> listOfCategories)
        {
            Randomizer rnd = Randomizer.GetInstance();
            List<Registration> listOfRegistrations = new List<Registration>();

            Console.WriteLine("\nPrijave natjecatelja:");
            foreach (Competitor competitor in listOfCompetitors)
            {
                Console.WriteLine("\nNatjecatelj: " + competitor.Name);
                int numberOfRegistratedThemes;
                if (maxThemeNumberPerCompetitor < numberOfThemes)
                    numberOfRegistratedThemes = rnd.GetNumber(1, maxThemeNumberPerCompetitor);
                else
                    numberOfRegistratedThemes = rnd.GetNumber(1, numberOfThemes);
                List<Theme> listOfRegistratedThemes = new List<Theme>();
                Console.WriteLine("Registrirane teme:");
                while (listOfRegistratedThemes.Count < numberOfRegistratedThemes)
                {
                    int themeIndex = rnd.GetNumber(0, numberOfThemes);
                    Theme registratedTheme = listOfThemes[themeIndex];
                    if (listOfRegistratedThemes.Contains(registratedTheme))
                        continue;
                    listOfRegistratedThemes.Add(registratedTheme);
                    Console.WriteLine(registratedTheme.Name);

                    int numberOfRegistratedCategories;

                    if(maxThemeNumberPerCompetitor < numberOfCategories)
                        numberOfRegistratedCategories = rnd.GetNumber(1, maxCategoryNumberPerCompetitor);
                    else
                        numberOfRegistratedCategories = rnd.GetNumber(1, numberOfCategories);

                    List<string> listOfregistratedCategories = new List<string>();
                    while (listOfregistratedCategories.Count < numberOfRegistratedCategories)
                    {
                        int categoryIndex = rnd.GetNumber(0, numberOfCategories);
                        string registratedCategory = listOfCategories[categoryIndex];
                        if (listOfregistratedCategories.Contains(registratedCategory))
                            continue;
                        listOfregistratedCategories.Add(registratedCategory);
                        Console.WriteLine("Kategorija: " + registratedCategory);

                        IFotoaparat camera = GetCamera(registratedCategory);
                        Console.WriteLine("Koristi fotoaparat: " + camera.GetModelName());

                        Registration registration = new Registration(competitor, registratedTheme, registratedCategory, camera, new Photo());
                        listOfRegistrations.Add(registration);
                    }
                }
            }

            return listOfRegistrations;
        }
Ejemplo n.º 4
0
 public abstract float GenerateScore(Registration registration);
Ejemplo n.º 5
0
 public abstract float GenerateScore(Registration registration);