static void Main(string[] args) { List <Learner> learners = new List <Learner>(); Student student1 = new Student(100, "Petua", "V541"); Student student2 = new Student(500, "Vlad", "K654"); Schoolboy schoolboy1 = new Schoolboy(1000, "Oleg", "GrodnoSchool123"); Schoolboy schoolboy2 = new Schoolboy(500, "Vasua", "MinskSchool543"); Money(schoolboy1, schoolboy2); Task(student1, student2); Console.WriteLine(schoolboy1.GetDocument()); Console.WriteLine(student2.GetDocument()); learners.Add(student1); learners.Add(student2); learners.Add(schoolboy1); learners.Add(schoolboy2); foreach (var item in learners) { if (item.GetType() == typeof(Student)) { Console.WriteLine(item.Name + " - Student"); } if (item.GetType() == typeof(Schoolboy)) { Console.WriteLine(item.Name + " - Schoolboy"); } } }
static void Money(Schoolboy obj1, Schoolboy obj2) { if (obj1.GetPower() > obj2.GetPower()) { Console.WriteLine("Schoolboy1 has taken the money of Schoolboy2"); } else if (obj1.GetPower() < obj2.GetPower()) { Console.WriteLine("Schoolboy2 has taken the money of Schoolboy1"); } else { Console.WriteLine("They both have gone to the prison"); } }