Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        private void Fun1()
        {
            Class1 c1 = new Class1(5);
            c1.ok();
            Console.WriteLine(c1.K3);
            Struct2 s2 = new Struct2(6);
            s2.ok();
            //  Console.WriteLine(s2.K3);
            Team team = new Team();
            team.AddMember(new Employee("Anders", "Developer", 26));
            team.AddMember(new Employee("Bill", "Developer", 46));
            team.AddMember(new Employee("Steve", "CEO", 36));

            Team clone = team.Clone() as Team;

            // Display the original team.
            Console.WriteLine("Original Team:");
            Console.WriteLine(team);

            // Display the cloned team.
            Console.WriteLine("Clone Team:");
            Console.WriteLine(clone);

            // Make changes.
            Console.WriteLine("*** Make a change to original team ***");
            Console.WriteLine(Environment.NewLine);
            team.TeamMembers[0].Title = "PM";
            team.TeamMembers[0].Age = 30;
            Console.WriteLine(team);

            Console.WriteLine("*** Student ***");
            Student student = new Student(15, "Tim");
            Student cloneStudent = student.Clone() as Student;
            Console.WriteLine(student);
            Console.WriteLine(cloneStudent);
            Console.WriteLine("*** Change Student ***");
            cloneStudent.age = 16;
            cloneStudent.Name = "Jacy";
            Console.WriteLine(student);
            Console.WriteLine(cloneStudent);
        }