Example #1
0
        static void Main(string[] args)
        {
            Student Stud          = new Student();
            Person  Person1       = new Person("1", "1", new DateTime(1, 1, 1));
            Person  SameAsPerson1 = new Person("1", "1", new DateTime(1, 1, 1));
            Person  Person2       = new Person("2", "2", new DateTime(1, 1, 1));

            Console.WriteLine("Eguals: {0}", Person1.Equals(Person2));
            Console.WriteLine("GetHachCod1: {0} \nGetHachCod2: {1}", Person1.GetHashCode(), Person2.GetHashCode());

            Stud.DateStudent = new Person("Test", "Student", new DateTime(1997, 5, 21));
            Stud.Education   = Education.Master;
            Stud.NamberGrup  = 402;
            Examp Ex1 = new Examp("English", 3, new DateTime(2017, 12, 11));
            Examp Ex2 = new Examp("Programing", 5, new DateTime(2017, 12, 24));
            Test  Ts1 = new Test("Art", true);
            Test  Ts2 = new Test("Java", true);
            Test  Ts3 = new Test("Visual Basic", false);

            Console.WriteLine("-------------------------------------------------------");

            Console.WriteLine(Person1 == SameAsPerson1);

            Stud.InformatoinExamp.Add(Ex1);
            Stud.InformatoinExamp.Add(Ex2);

            Stud.InformationTest.Add(Ts1);
            Stud.InformationTest.Add(Ts2);
            Stud.InformationTest.Add(Ts3);

            Console.WriteLine(Stud);
            Console.WriteLine(Stud.DateStudent);

            Student StudCopi = new Student();

            StudCopi        = Stud.DeepCopy() as Student;
            Stud.NamberGrup = 302;
            Console.WriteLine("Original--------");
            Console.WriteLine(Stud);
            Console.WriteLine("Copy--------");
            Console.WriteLine(StudCopi);


            try
            {
                Stud.NamberGrup = 99;
            }catch (Exception ex)
            {
                Console.WriteLine("Помилка");
            }


            foreach (Examp param in Stud.GetExampParams(3))
            {
                Console.WriteLine(param);
            }

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Person person1 = new Person("Serhiy", "Pityk", new DateTime(2000, 3, 27));
            Person person2 = new Person("Serhiy", "Pityk", new DateTime(2000, 3, 27));

            if (person1.Equals(person2))
            {
                Console.WriteLine("Objects are equals");
            }
            else
            {
                Console.WriteLine("Oblects are not equals");
            }
            Console.WriteLine(person1.GetHashCode());
            Console.WriteLine(person2.GetHashCode());


            Student student = new Student(person1, Education.Bachelor, 312);

            System.Collections.ArrayList tests = new System.Collections.ArrayList();
            tests.Add(new Test("Math", true));
            tests.Add(new Test("English", true));
            tests.Add(new Test("Programming", true));
            student.Testss = tests;
            System.Collections.ArrayList exams = new System.Collections.ArrayList();
            exams.Add(new Exam("NETCore", 90, new DateTime(2020, 4, 13)));
            exams.Add(new Exam("JavaCore", 95, new DateTime(2020, 4, 10)));
            exams.Add(new Exam("PHP", 70, new DateTime(2020, 4, 5)));
            student.Examss = exams;
            Console.WriteLine(student.ToString());


            Console.WriteLine(student.Info.GetName());
            Console.WriteLine(student.Info.GetSurname());
            Console.WriteLine(student.Info.GetBirthDate().ToString());

            Student studentCopy = (Student)student.DeepCopy();

            student.SetName("Artem");
            student.SetSurname("Shtefanesa");
            student.SetBirthDate(new DateTime(1999, 2, 10));
            if (student == studentCopy)
            {
                Console.WriteLine("Something went wrong");
            }
            else
            {
                Console.WriteLine("Objects arent equals");
            }


            try
            {
                student.GroupNumberr = 50;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            foreach (Exam exam in student.GetEnumeratorMoreThan(80))
            {
                Console.WriteLine(exam.Mark);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Person person1 = new Person("Les", "Podervlansky", new DateTime(1998, 1, 2));
            Person person2 = new Person("Les", "Podervlansky", new DateTime(1998, 1, 2));

            if (person1.Equals(person2))
            {
                Console.WriteLine("Are equal.");
            }
            else
            {
                Console.WriteLine("Are not equal.");
            }
            Console.WriteLine(person1.GetHashCode());
            Console.WriteLine(person2.GetHashCode());


            Student student = new Student(person1, Education.Bachelor, 302);

            System.Collections.ArrayList tests = new System.Collections.ArrayList();
            tests.Add(new Test("Calculus", true));
            tests.Add(new Test("Differential Equations", true));
            tests.Add(new Test("Algebra", true));
            student.Testss = tests;
            System.Collections.ArrayList exams = new System.Collections.ArrayList();
            exams.Add(new Exam("JavaScript", 77, new DateTime(2020, 1, 31)));
            exams.Add(new Exam("Web-Design", 95, new DateTime(2020, 1, 28)));
            exams.Add(new Exam("Economics", 81, new DateTime(2020, 1, 25)));
            student.Examss = exams;
            Console.WriteLine(student.ToString());


            Console.WriteLine(student.Info.FirstName);
            Console.WriteLine(student.Info.Surname);
            Console.WriteLine(student.Info.DateOfBirth.ToString());

            Student studentCopy = (Student)student.DeepCopy();

            student.FirstName   = "Les";
            student.Surname     = "Claypool";
            student.DateOfBirth = new DateTime(1996, 1, 2);
            if (student == studentCopy)
            {
                Console.WriteLine("Error occured");
            }
            else
            {
                Console.WriteLine("Are not equal.");
            }


            try
            {
                student.GroupNumber = 30;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            foreach (Exam exam in student.GetEnumeratorMoreThan(80))
            {
                Console.WriteLine(exam.Mark);
            }
        }