예제 #1
0
        static void Main(string[] args)
        {
            Tardis     mytardis = new Tardis();
            PhoneBooth mybooth  = new PhoneBooth();

            UsePhone(mytardis);
            UsePhone(mybooth);
        }
예제 #2
0
        static void UsePhone(object obj)
        {
            PhoneInterface phone = (PhoneInterface)obj;

            phone.MakeCall();

            if (obj.GetType() == typeof(PhoneBooth))
            {
                PhoneBooth booth = (PhoneBooth)obj;
                booth.OpenDoor();
            }
            else if (obj.GetType() == typeof(Tardis))
            {
                Tardis tardis = (Tardis)obj;
                tardis.TimeTravel();
            }
        }