Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- namespace lab5
- {
- class MainClass
- {
- public interface IGetInfo
- {
- void print();
- }
- public enum CourseOfStudy
- {
- First, Second, Third, Fourth
- }
- public class Person : IComparable<Person>, IGetInfo
- {
- protected int age;
- protected string name, surname;
- public int CompareTo(Person other)
- {
- return other.age.CompareTo(this.age);
- }
- public Person(int age, string name, string surname)
- {
- this.age = age;
- this.name = name;
- this.surname = surname;
- }
- public virtual void print ()
- {
- Console.WriteLine("Age = " + age);
- Console.WriteLine("Name = " + name);
- Console.WriteLine("Surname = " + surname);
- }
- }
- public class Student : Person
- {
- protected CourseOfStudy currCourse;
- protected string university;
- public Student(int age, string name , string surname, CourseOfStudy course, string university)
- :base(age, name, surname)
- {
- this.currCourse = course;
- this.university = university;
- }
- public override void print ()
- {
- base.print();
- Console.WriteLine("University = " + university);
- Console.WriteLine("Course = " + currCourse);
- }
- }
- public class StudentOfCSaN
- {
- protected string speciality;
- public StudentOfCSaN(string speciality)
- {
- this.speciality = speciality;
- }
- public void print()
- {
- Console.WriteLine("Speciality = " + speciality);
- }
- }
- public static void Main(string[] args)
- {
- List <Person> my = new List<Person>();
- my.Add(new Person(123, "a", "fdj"));
- my.Add(new Person(2223, "b", "fdj"));
- my.Add(new Person(1333, "c", "fdj"));
- my.Add(new Person(123, "d", "fdj"));
- my.Sort();
- foreach(var t in my)
- {
- t.print();
- Console.WriteLine();
- }
- Console.WriteLine();
- /*List<Student> my2 = new List<Student>();
- my2.Add(new Student(123, "a", "ds", (CourseOfStudy)2, "qew"));
- my2.Add(new Student(113, "a", "ds", (CourseOfStudy)2, "qew"));
- my2.Add(new Student(13123, "a", "ds", (CourseOfStudy)2, "qew"));
- my2.Add(new Student(123333, "a", "ds", (CourseOfStudy)2, "qew"));
- my2.Sort();
- foreach(var t in my2)
- {
- t.print();
- Console.WriteLine();
- }*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement