Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hnatyshyn Mykhailo, IP-72, Variant #5");


            Console.WriteLine();
            Student me = new Student("Mykhailo", "Hnatyshyn", new DateTime(1998, 06, 14), Student.Education.Bachelor, "IP-72", "IP-7207");

            Console.WriteLine(me.ToString());
            me.AddExams(new Examination[]
            {
                new Examination(3, "Object-oriented programming (OOP)", "Muha I.P.", 75, true, new DateTime(2018, 04, 11)),
                new Examination(1, "Mathematical analysis", "Bodnarchuk S.W.", 91, true, new DateTime(2017, 11, 25)),
                new Examination(2, "Discrete structures", "Halkin S.V.", 98, false, new DateTime(2019, 05, 02)),
                new Examination(4, "Web technologies", "Ocheretianyj O.D.", 100, false, new DateTime(2019, 10, 02)),
                new Examination(5, "Probability theory", "Harko I.D.", 85, true, new DateTime(2019, 10, 02)),
                new Examination(3, "Theory of algorithms", "Halus O.M.", 75, true, new DateTime(2017, 11, 05)),
                new Examination(2, "Philosophy", "Anapov O.D.", 68, false, new DateTime(2019, 10, 02)),
            });
            Console.WriteLine(me.ToString());
            me.PrintFullInfo();

            Console.WriteLine();

            Console.WriteLine("Task 1: ");
            Student student = new Student("Mykhailo", "Hnatyshyn", new DateTime(1999, 11, 11), Student.Education.Bachelor, "IP-72", "IP-7207");

            student.AddExams(new Examination[]
            {
                new Examination(3, "Object-oriented programming (OOP)", "Muha I.P.", 75, true, new DateTime(2018, 04, 11)),
                new Examination(1, "Mathematical analysis", "Bodnarchuk S.W.", 91, true, new DateTime(2017, 11, 25)),
            });
            Student clone = (Student)student.Clone();

            student.AddExam(new Examination(4, "Web technologies", "Ocheretianyj O.D.", 100, false, new DateTime(2019, 10, 02)));
            Console.WriteLine("Link to student != Link to clone : " + (student == clone));
            Console.WriteLine("student credits after adding one to it : ");
            student.GetCredits();
            Console.WriteLine("clone credits after adding one to student : ");
            clone.GetCredits();

            Console.WriteLine();

            Console.WriteLine("Task 2: ");
            Person person1 = new Person("Bohdan", "Kotenko", new DateTime(1999, 11, 11));
            Person person2 = new Person("Bohdan", "Kotenko", new DateTime(1999, 11, 11));
            Person person3 = new Person("Misha", "Afanasiuk", new DateTime(1996, 01, 27));

            Console.WriteLine("Bohdan Kotenko 11.11.1999 == Bohdan Kotenko 11.11.1999 : " + (person1 == person2));
            Console.WriteLine("Bohdan Kotenko 11.11.1999 == Misha Afanasiuk 27.01.1999 : " + (person1 == person3));
            Console.WriteLine("Bohdan Kotenko 11.11.1999 != Bohdan Kotenko 11.11.1999 : " + (person1 != person2));
            Console.WriteLine("Bohdan Kotenko 11.11.1999 != Misha Afanasiuk 27.01.1999 : " + (person1 != person3));
            Console.WriteLine();

            Console.WriteLine("Task 9: ");
            Console.WriteLine("Not differentiated credit: ");
            foreach (Examination exm in me.GetNotExaminations())
            {
                Console.WriteLine(exm);
            }
            Console.WriteLine();

            Console.WriteLine("Task 12: ");
            Console.WriteLine("Exams sorted by subject name: ");
            me.GetCredits();
            Console.WriteLine();

            Console.Write("Press key to exit...");
            Console.ReadKey();
        }
Example #2
0
File: Program.cs Project: PakVl/OOP
        static void Main(string[] args)
        {
            Person Chel1 = new Person();
            Person Chel2 = new Person();

            Console.WriteLine("Персоны: ");
            Console.WriteLine("1) " + Chel1.ToString());
            Console.WriteLine("2) " + Chel2.ToString());
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("Сравнения : ");
            Console.WriteLine(string.Format("Совпадение: {0}", Chel1.Equals((object)Chel2)));
            Console.WriteLine(string.Format("Хеш код 1 человека: {0} Хеш код 2 человека: {1} ", Chel1.GetHashCode(), Chel2.GetHashCode()));
            Console.WriteLine();
            Console.ReadKey();

            Student Stud1 = new Student();
            Stud1.FieldListExam.Add(new Exam("Алгебра", 5, new DateTime(2001, 10, 10)));
            Stud1.FieldListExam.Add(new Exam("Физика", 4, new DateTime(2001, 10, 11)));
            Stud1.FieldListExam.Add(new Exam("Магия", 3, new DateTime(2001, 10, 09)));
            Stud1.FieldListTest.Add(new Test("Базы данных", true));
            Stud1.FieldListTest.Add(new Test("Философия", false));
            Console.WriteLine("Студент: ");
            Console.WriteLine(Stud1.ToString());
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("Cвойство типа Person для объекта типа Student: ");
            Console.WriteLine(Convert.ToString(Stud1.FieldDateOfBirth));
            Console.ReadKey();
            Console.WriteLine();
            Student Stud2 = (Student)Stud1.DeepCopy();

            Stud1.FieldName = "Никита";
            Stud1.FieldGroup = 500;
            Console.WriteLine("Исходный: ");
            Console.WriteLine(Stud1.ToShortString());
            Console.WriteLine("Копия: ");
            Console.WriteLine(Stud2.ToShortString());
            Console.ReadKey();
            Console.WriteLine();

            Console.WriteLine("Отлов ошибки: ");
            try
            {
                Stud1.FieldGroup = 10;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
            Console.WriteLine();
            Stud1.List();

            Console.WriteLine("Итератор Объектов: ");
            foreach (object e in Stud1.GetStudExTest())
            {
                Console.WriteLine(Convert.ToString(e));
            }
            Console.ReadKey();
            Console.WriteLine();

            Console.WriteLine("Итератор условный: ");
            foreach (Exam e in Stud1.GetStudEx())
            {
                Console.WriteLine(Convert.ToString(e));
            }
            Console.ReadKey();
            Console.WriteLine();
        }
Example #3
0
        public string Timer()
        {
            Student       first, middle, last, none = new Student();
            int           n   = person.Count;
            StringBuilder rez = new StringBuilder("");

            first = middle = last = null;

            PersonStudent.TryGetValue(person[0], out first);

            PersonStudent.TryGetValue(person[n / 2], out middle);

            PersonStudent.TryGetValue(person[n - 1], out last);

            rez.Append("\n First: \n");

            int    time     = Environment.TickCount;
            string toString = first.ToString();

            for (int i = 0; i < 1000000; i++)
            {
                person.Contains(first.Person);
            }

            rez.Append("List person: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                str.Contains(toString);
            }

            rez.Append("list string: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                PersonStudent.ContainsKey(first.Person);
            }

            rez.Append("PersonStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                StringStudent.ContainsKey(toString);
            }

            rez.Append("StringStudent: " + (Environment.TickCount - time) + "\n");

            rez.Append("\n Middle: \n");

            time     = Environment.TickCount;
            toString = middle.ToString();

            for (int i = 0; i < 1000000; i++)
            {
                person.Contains(middle.Person);
            }

            rez.Append("List person: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                str.Contains(toString);
            }

            rez.Append("list string: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                PersonStudent.ContainsKey(middle.Person);
            }

            rez.Append("PersonStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                StringStudent.ContainsKey(toString);
            }

            rez.Append("StringStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            rez.Append("\n Last: \n");

            time     = Environment.TickCount;
            toString = last.ToString();

            for (int i = 0; i < 1000000; i++)
            {
                person.Contains(last.Person);
            }

            rez.Append("List person: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                str.Contains(toString);
            }

            rez.Append("list string: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                PersonStudent.ContainsKey(last.Person);
            }

            rez.Append("PersonStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                StringStudent.ContainsKey(toString);
            }

            rez.Append("StringStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            rez.Append("\n None: \n");

            time     = Environment.TickCount;
            toString = none.ToString();

            for (int i = 0; i < 1000000; i++)
            {
                person.Contains(none.Person);
            }

            rez.Append("List person: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                str.Contains(toString);
            }

            rez.Append("list string: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                PersonStudent.ContainsKey(none.Person);
            }

            rez.Append("PersonStudent: " + (Environment.TickCount - time) + "\n");
            time = Environment.TickCount;

            for (int i = 0; i < 1000000; i++)
            {
                StringStudent.ContainsKey(toString);
            }

            rez.Append("StringStudent: " + (Environment.TickCount - time) + "\n");

            return(rez.ToString());
        }
Example #4
0
        static void Main(string[] args)
        {
            int    a   = 16;
            string qwe = "sdfsd";

            Console.WriteLine(qwe.GetType());
            int     b    = 16;
            Student yan  = new Student("yan", "bgtu", 18);
            Student non  = new Student();
            Student yan1 = new Student(yan);
            Student qw1  = new Student("qwe", "wer", 1);
            Student qw2  = new Student("ccc", "dsf", 6);

            yan.print();
            non.print();
            yan1.print();
            Console.WriteLine(yan.Equals(yan1));
            Console.WriteLine(yan.Equals(non));
            Console.WriteLine(Student.count);
            Console.WriteLine(Student.polovina());
            Console.WriteLine(yan1.ToString());
            Console.WriteLine(yan1.type);
            yan.ageout(out a);
            Console.WriteLine(a);
            yan.changeage(ref b);
            yan.print();
            yan.part();
            var stud = new { name = "kek", edu = "lol", age = 10 };

            List <Student> list1 = new List <Student>();

            list1.Add(yan);
            list1.Add(qw1);
            list1.Add(yan1);
            list1.Add(qw2);
            string poisk = Console.ReadLine();

            foreach (var item in list1)
            {
                if (item.name == poisk)
                {
                    Console.WriteLine("pobeda");
                }
                else
                {
                    Console.WriteLine("ne pobeda");
                }
            }


            BuildCollection <Student> Col = new BuildCollection <Student>(10);

            Col.Add(yan);
            Col.Get(0);
            Col.Add(yan1);
            Col.Add(yan1);
            Console.WriteLine(Col.Count);
            Col.Remove(yan);
            Console.WriteLine(Col.Count);
            Console.WriteLine(Col.Contains(yan1));
        }