Esempio n. 1
0
        static void Main(string[] args)
        {
            int personsCount = 0;

            if ((args.Count() < 2) || !int.TryParse(args[1], out personsCount) || (personsCount < 1))
            {
                Console.WriteLine("Input parameter error");
                return;
            }
            PersonLocaleSettings personLocalSettings = new PersonLocaleSettings();

            if (!personLocalSettings.Load(args[0]))
            {
                Console.WriteLine("Input locale error");
                return;
            }
            double averageMistakesCount = 0;

            if ((args.Count() > 2) && (!double.TryParse(args[2], out averageMistakesCount) || (averageMistakesCount < 0)))
            {
                Console.WriteLine("Input parameter error");
                return;
            }
            Person[]          persons           = new Person[personsCount];
            BaseForGeneration baseForGeneration = new BaseForGeneration();

            baseForGeneration.Load(args[0]);
            Random rnd = new Random();

            for (int i = 0; i < personsCount; ++i)
            {
                persons[i] = new Person(rnd, baseForGeneration, personLocalSettings);
            }
            if (averageMistakesCount > 0)
            {
                MakeMistakes(averageMistakesCount * personsCount, rnd, persons, args[0]);
            }
            for (int i = 0; i < personsCount; ++i)
            {
                persons[i].Print(personLocalSettings);
                Console.WriteLine();
            }
        }
Esempio n. 2
0
 public Person(Random rnd, BaseForGeneration baseForGeneration, PersonLocaleSettings personLocalSettings)
 {
     surname = baseForGeneration.surnames[rnd.Next(0, baseForGeneration.surnames.Count())];
     name    = baseForGeneration.names[rnd.Next(0, baseForGeneration.names.Count())];
     if (baseForGeneration.patronymics != null)
     {
         patronymic = baseForGeneration.patronymics[rnd.Next(0, baseForGeneration.patronymics.Count())];
     }
     else
     {
         patronymic = "";
     }
     city      = baseForGeneration.cities[rnd.Next(0, baseForGeneration.cities.Count())];
     street    = baseForGeneration.streets[rnd.Next(0, baseForGeneration.streets.Count())];
     house     = rnd.Next(1, 50).ToString();
     room      = rnd.Next(1, 108).ToString();
     telephone = rnd.Next(1000001, 9999999).ToString();
     postCode  = rnd.Next(personLocalSettings.postCode, personLocalSettings.postCode * 10 - 1).ToString();
 }