Ejemplo n.º 1
0
        public Registration(Competitor competitor, Theme theme, string category, IFotoaparat camera, Photo photo)
        {
            RegistrationHandler registrationHandler = RegistrationHandler.GetInstance();
            id = "PRIJAVA " + registrationHandler.Counter.ToString();
            registrationHandler.Counter++;

            disqualified = false;
            this.competitor = competitor;
            this.theme = theme;
            this.category = category;
            this.camera = camera;
            this.photo = photo;
        }
Ejemplo n.º 2
0
        public Registration(Competitor competitor, Theme theme, string category, IFotoaparat camera, Photo photo)
        {
            RegistrationHandler registrationHandler = RegistrationHandler.GetInstance();

            id = "PRIJAVA " + registrationHandler.Counter.ToString();
            registrationHandler.Counter++;

            disqualified    = false;
            this.competitor = competitor;
            this.theme      = theme;
            this.category   = category;
            this.camera     = camera;
            this.photo      = photo;
        }
        /// <summary>
        /// Funkcija koja generira natjecatelje,e zajedno sn jihovim imenima i prezimenima
        /// </summary>
        /// <param name="numberOfCompetitors">Broj natjecatelja</param>
        /// <returns>Lista natjecatelja</returns>
        private List<Competitor> GenerateCompetitors(int numberOfCompetitors)
        {
            #region Pronalazaz direktorija s imenima i prezimenima
            string namesLocation = DirectoryLocator.GetDirectory("Person Names", Directory.GetCurrentDirectory(), 0, 3);
            string surnamesLocation = DirectoryLocator.GetDirectory("Person Surnames", Directory.GetCurrentDirectory(), 0, 3);
            if (string.Equals("ERROR", namesLocation) || string.Equals("ERROR", surnamesLocation))
            {
                return null;
            }
            #endregion

            #region Učitavanje listi imena i perzimena
            List<string> listOfNames = new List<string>();
            string[] files1 = Directory.GetFiles(namesLocation);
            foreach (string file in files1)
            {
                Console.WriteLine("Učitavam imena iz " + file);
                string[] lines = System.IO.File.ReadAllLines(file);

                foreach (string line in lines)
                {
                    string name = line;
                    if (listOfNames.Contains(name) || string.Equals(name, ""))
                        continue;
                    listOfNames.Add(name);
                }
            }

            List<string> listOfSurnames = new List<string>();
            string[] files2 = Directory.GetFiles(surnamesLocation);
            foreach (string file in files2)
            {
                Console.WriteLine("Učitavam prezimena iz " + file);
                string[] lines = System.IO.File.ReadAllLines(file);

                foreach (string line in lines)
                {
                    string surname = line;
                    if (listOfSurnames.Contains(surname) || string.Equals(surname, ""))
                        continue;
                    listOfSurnames.Add(surname);
                }
            }
            #endregion

            #region Generiranje natjecatelja
            List<Competitor> competitors = new List<Competitor>();
            List<string> listOfCompetitorNames = new List<string>();
            Randomizer rnd = Randomizer.GetInstance();
            while(competitors.Count < numberOfCompetitors)
            {
                int nameIndex = rnd.GetNumber(0, listOfNames.Count);
                string name = listOfNames[nameIndex];

                int surnameIndex = rnd.GetNumber(0, listOfSurnames.Count);
                string surname = listOfSurnames[surnameIndex];

                string competitorName = name + " " + surname;
                if(rnd.GetNumber(0, 7) == 4)
                {
                    //Dodajemo i drugo prezime
                    int secondSurnameIndex = rnd.GetNumber(0, listOfSurnames.Count);
                    string secondSurname = listOfSurnames[secondSurnameIndex];
                    if(!string.Equals(surname, secondSurname))
                    {
                        competitorName = competitorName + "-" + secondSurname;
                    }
                }

                if (!listOfCompetitorNames.Contains(competitorName))
                {
                    listOfCompetitorNames.Add(competitorName);
                    Competitor competitor = new Competitor(competitorName);
                    competitors.Add(competitor);
                }
            }
            #endregion

            return competitors;
        }