static void Main(string[] args) { object tardy = new Tardis(); object boxman = new PhoneBooth(); UsePhone(tardy); UsePhone(boxman); }
static void UsePhone(object obj) { Console.ReadLine(); IPhoneInterface lance = (IPhoneInterface)obj; PhoneBooth spear = (PhoneBooth)obj; Tardis glaive = (Tardis)obj; lance.MakeCall(); lance.HangUp(); if (lance == spear) { spear.OpenDoor(); } if (obj == glaive) { glaive.TimeTravel(); } }