Exemplo n.º 1
0
        public static void TestVirtualMethod()
        {
            // giorgi
            Student giorgi = new Bachelor();
            giorgi.Name = "giorgi";
            giorgi.LastName = "giorgadze";
            // avto
            Master master = new Master();
            master.Name = "avto";
            master.LastName = "rukhadze";
            master.Credits = new[] { 100, 50 };  // summary credits 150

            Student avto1 = master;

            Console.WriteLine(avto1.Passed()); // True
            Master avto2 = master;
            Console.WriteLine(avto2.Passed()); // True

            Student[] dataBase = new Student[]
            {
                new Master() {Credits = new int[] {100, 150}, Name = "avto"},
                new Bachelor() {Credits = new int[] {200, 50}, Name = "giorgi"},
                new Master() {Credits = new int[] {100, 150}, Name = "avto"},
                new Bachelor() {Credits = new int[] {200, 50}, Name = "giorgi"},
                new Master() {Credits = new int[] {100, 150}, Name = "avto"},
                new Bachelor() {Credits = new int[] {200, 50}, Name = "giorgi"},
                new Master() {Credits = new int[] {100, 150}, Name = "avto"},
                new Bachelor() {Credits = new int[] {200, 50}, Name = "giorgi"},
            };

            int res = 0;
            foreach (var student in dataBase)
            {
                if (student.Passed()) res++;
            }
            Console.WriteLine(res);
        }
Exemplo n.º 2
0
 public static void AddStudent(Student stud)
 {
     StudentCount++;
 }