public Date(int day, int month, int year)
public void SetDay(int day)
public void SetMonth(int month)
public void Setyear(int year)
public int CompareTo(Date d)
if (this.month == d.month)
return this.month - d.month;
return this.year - d.year;
return this.day + "/" + this.month + "/" + this.year;
Console.WriteLine("enter day");
day = int.Parse(Console.ReadLine());
Console.WriteLine("enter month");
month = int.Parse(Console.ReadLine());
Console.WriteLine("enter year");
year = int.Parse(Console.ReadLine());
Date d = new Date(day,month,year);
public Student(string name, Date birth, int[] grades)
public Student(Student d)
public void SetName(string name)
public void SetBirth(Date birth)
public void SetGrades(int[] grades)
public double AvgGrades()
for (int i = 0; i < this.grades.Length; i++)
avg = avg + this.grades[i];
return avg / this.grades.Length;
public bool Older(Student t)
if (this.birth.CompareTo(t.birth) < 0)
public string ToString(Student t)
return "Name: " + this.name + ", " + "Birth: " + this.birth + ", " + "Grades:" + this.grades + ", " + "Average; " + t.AvgGrades();
public void BuildStudent()
int[] grades = new int[4];
Console.WriteLine("enter name");
name = Console.ReadLine();
Console.WriteLine("enter day");
day = int.Parse(Console.ReadLine());
Console.WriteLine("enter month");
month = int.Parse(Console.ReadLine());
Console.WriteLine("enter year");
year = int.Parse(Console.ReadLine());
Date d = new Date(day,month,year);
for(int i = 0; i < 4; i++)
Random rnd = new Random();
int num = rnd.Next(40 , 101);
public static void Main()
Date date = new Date(date.build());
Console.WriteLine("your date is" + date.ToString());
Date date2 = new Date(1, 12, 1980);
Console.WriteLine("your secound date is" + date2.ToString());
Console.WriteLine("if the number is positive that's mean that the first date is smaller then the secound date " + date.CompareTo(date2));
Student t = new Student(t.BuildStudent());