using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication2
{
class Lab3
{
private const int N = 3;
private string date;
public int counter = 0;
char[] str = new char[11];
Person[] a = new Person[N];
Random rand = new Random();
public struct idk
{
public string name;
public string surname;
public string fth;
}
public struct Date
{
public int year;
public int mth;
public int day;
}
public struct Person
{
public idk fio;
public int ChildAmount;
public string[] ChildBrth;
}
string creator_fio(char[] str1)
{
string Newtext = "";
for (int i = 0; i < 6; i++)
{
int x = rand.Next(97,122);
str1[i] = Convert.ToChar(x);
// str1 += str1[i];
str1[0] = Convert.ToChar(x - 32);
}
return Convert.ToString(str1);
}
string creator_date(string str1)
{
Date idk;
int year, mth, day;
year = rand.Next(1990, 2013);
mth = rand.Next(1,12);
if ((mth == 2) && (year % 4 == 0))
day = rand.Next(1,28);
else if ((mth % 2 == 0) && (mth != 2))
day = rand.Next(1, 30);
else
day = rand.Next(1, 31);
str1 = Convert.ToString(idk.year = year) + '.';
str1 += Convert.ToString(idk.mth = mth) + '.';
str1 += Convert.ToString(idk.day = day);
return str1;
}
int calculator(string str1)
{
int i = 0, cnt = 0;
int[] date = new int[3];
while ((str1[i] != '.') && (i < 3))
{
date[i] = Convert.ToInt32(str1);
i++;
}
if ((date[0] <= 1996) && (date[1] <= 12) && (date[2] <= 12))
cnt++;
return cnt;
}
public Lab3()
{
for (int i = 0; i < N; i++)
{
//int counter = 0;
int x = rand.Next(1,5);
a[i].fio.name = creator_fio(str);
a[i].fio.surname = creator_fio(str);
a[i].fio.fth = creator_fio(str);
a[i].ChildAmount = x;
for (int j = 0; j < x; j++)
{
a[i].ChildBrth[j] += creator_date(date);
counter += calculator(a[i].ChildBrth[j]);
}
}
}
public string print(int cnt)
{
string NewText = "";
NewText += cnt;
return NewText;
}
}
}