static void Main(string[] args) { Person a = new Person("Umar", "Sharifor", new DateTime(1999, 06, 23)); Person b = new Person("Umar", "Sharifor", new DateTime(1999, 06, 23)); Console.WriteLine(" Object A: " + a.ToString() + " \n Object B: " + b.ToString()); Console.WriteLine("\n We will change Object B.name will be SomeName and after show \n"); b.setName("SomeName"); Console.WriteLine(" Object A: " + a.ToString() + " \n Object B: " + b.ToString()); Console.WriteLine("\n How we saw, the links of object is not same, we will go back and change\n" + "b.name to Umar and chack the values of objects A and B \n"); b.setName("Umar"); if (a == b) { Console.WriteLine("the values of objects is equal\n"); } else { Console.WriteLine("the values of objects is not equal\n"); } Console.WriteLine("Hash Code of object A " + a.GetHashCode()); Console.WriteLine("Hash Code of object B " + b.GetHashCode()); Student stud1 = new Student(new Person("Umar", "Sharifor", new DateTime(1999, 06, 23)), Education.Bachelor, 762); stud1.AddExam(); stud1.AddOffsets(); Console.WriteLine(stud1.ToString()); Person studperson = stud1.GetPerson(); Console.WriteLine(studperson.ToString()); Student stud2 = new Student(); object stud3 = stud1.DeepCopy(); stud2 = (Student)stud3; Console.WriteLine(" first student" + stud1.ToString()); Console.WriteLine(" second student" + stud3.ToString()); Console.WriteLine("first and second student ofter changes\n"); stud1.setName("Karim"); Console.WriteLine("We changed the name of first student and show both students\n"); Console.WriteLine(" first student" + stud1.ToString()); Console.WriteLine(" second student" + stud3.ToString()); Console.WriteLine("Спикос экзаменов и зачетов"); foreach (object t in stud1) { if (t is Exam) { Exam temp = (Exam)t; Console.WriteLine(temp.ToString()); } else { Test temp = (Test)t; Console.WriteLine(temp.ToString()); } } Console.WriteLine("Список экзаменов у который оценка больше 3"); foreach (object t in stud1.GetEnumarator(3)) { Exam temp = (Exam)t; Console.WriteLine(temp.ToString()); } Console.ReadLine(); }
public void SetPerson(Person person) { name = person.getName(); secondName = person.getSecondName(); birth = person.Date; }