Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        static void UsePhone(object obj)
        {
            Phone           phone           = (Phone)obj;
            IPhoneInterface iphoneInterface = null;

            phone.MakeCall();
            phone.HangUp();


            if (phone.GetType() == typeof(Tardis))
            {
                iphoneInterface = (IPhoneInterface)phone;
                phone.TimeTravel();
            }
            if (phone.GetType() == typeof(PhoneBooth))
            {
                iphoneInterface = (IPhoneInterface)phone;
                phone.OpenDoor();
            }
        }
Exemplo n.º 3
0
 public PhoneFactory(IPhoneInterface phoneInterface)
 {
     _phoneInterface = phoneInterface;
 }