static void Main(string[] args) { /////////////1//////////////// Sea s = new Sea("Clear", "Black"); s.Display(); Country coun = new Country("New Land", "Russia"); coun.ReWrite(); /////////////6//////////////// Console.WriteLine(coun.ToString()); /////////////6//////////////// /////////////1//////////////// /////////////2//////////////// Person p1 = new Person("Bill"); p1.Display(); // вызов метода Display из класса Person Employee p2 = new Employee("Tom", "Microsoft"); p2.Display(); // вызов метода Display из класса Person /////////////2//////////////// /////////////3//////////////// var sc = new SealedClass(); sc.x = 110; sc.y = 150; Console.WriteLine($"x = {sc.x}, y = {sc.y}"); /////////////3//////////////// /////////////4//////////////// Car1 c = new Car1(); c.Move(); /////////////4//////////////// /////////////5//////////////// if (p1 is Employee) { Employee emp1 = (Employee)p1; Console.WriteLine(emp1.Company); Employee emp = p1 as Employee; if (emp == null) { Console.WriteLine("Преобразование прошло неудачно"); } else { Console.WriteLine(emp.Company); } } else { Console.WriteLine("Преобразование не допустимо"); } /////////////5//////////////// /////////////7//////////////// Printer pr = new Printer(); var rn = new RunThing(); pr.IAmPrinting(rn); object[] arr = new object[2]; arr[0] = pr; arr[1] = sc; /////////////7//////////////// Console.ReadKey(); }
public void IAmPrinting(RunThing rn) { rn.Run(); Console.WriteLine("ToString() 7 exersize" + rn.ToString()); }