Ejemplo n.º 1
0
        public static void SetArray(Student[] list)
        {
            for (int i = 0; i < list.Length; i++)
            {
                int sp;
                Console.Write("Choose your specialty: IITP - 1, SIT - 2, EC - 3\n ");
                while (!int.TryParse(Console.ReadLine(), out sp) || sp < 1 || sp > 3)
                {
                    Console.Write("Wrong input, try again: ");
                }
                switch (sp)
                {
                case 1:
                    list[i] = new IITP {
                        Specialty = "Informatics"
                    };
                    SetParametrs(list[i]);
                    Console.WriteLine(); break;

                case 2:
                    list[i] = new SIT {
                        Specialty = "Software for Information Technologies"
                    };
                    SetParametrs(list[i]);
                    Console.WriteLine(); break;

                case 3:
                    list[i] = new EC {
                        Specialty = "Electronic Computing"
                    };
                    SetParametrs(list[i]);
                    Console.WriteLine(); break;
                }
            }

            Console.WriteLine("List of students:");
            for (int i = 0; i < list.Length; i++)
            {
                Console.WriteLine(list[i]);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Human.Show();
            Console.WriteLine();

            Student studentOne = new Student("Vladislav", "Piletskiy", 17, "IITP");

            Console.WriteLine(studentOne);
            Console.WriteLine();

            IITP informaticStudent = new IITP("Vladislav", "Piletskiy", 17, 9, 9, 9);

            Console.WriteLine(informaticStudent);

            SIT softwareStudent = new SIT("Andrew", "Oleshkevich", 18, 10, 10, 9);

            Console.WriteLine(softwareStudent);

            EC computingStudent = new EC("Alexey", "Dilevskiy", 17, 9, 10, 9);

            Console.WriteLine(computingStudent);

            Human.Show();
            Console.WriteLine();


            Student[] list = new Student[2];
            SetArray(list);
            Console.WriteLine();

            if (list[0].CompareTo(list[1]) == 0)
            {
                Console.WriteLine("Students have the same level of knowledge\n");
            }
            if (list[0].CompareTo(list[1]) == 1)
            {
                Console.WriteLine("The first student knows more than the second\n");
            }
            if (list[0].CompareTo(list[1]) == -1)
            {
                Console.WriteLine("The first student knows less than the second\n");
            }

            Console.WriteLine("Copy of the first student: ");
            Student st1 = (Student)list[0].Clone();

            Console.WriteLine(st1);

            Console.WriteLine("Copy of the second student:");
            Student st2 = (Student)list[1].Clone();

            Console.WriteLine(st2);

            foreach (Student s in list)
            {
                Console.WriteLine($"{s.Name}  {s.Surname} - Level: {s.CountLevel()}");
            }

            Human.Show();
            Console.WriteLine();

            Console.ReadKey();
        }