Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var mobilePhoneFactory = new MobilePhoneFactory();

            IMobilePhone mobilePhoneApple = mobilePhoneFactory.GetMobilePhone(MobilePhoneType.Apple);

            mobilePhoneApple.DisplayInfo();

            IMobilePhone mobilePhoneSamsung = mobilePhoneFactory.GetMobilePhone(MobilePhoneType.Samsung);

            mobilePhoneSamsung.DisplayInfo();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new AppleFactory(); // <-- Only(!) reference to vendor

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new SamsungFactory();

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
Exemplo n.º 4
0
        public IMobilePhone GetMobilePhone(MobilePhoneType type)
        {
            IMobilePhone mobilePhone = null;

            switch (type)
            {
            case MobilePhoneType.Apple:
                mobilePhone = new Apple();
                break;

            case MobilePhoneType.Samsung:
                mobilePhone = new Samsung();
                break;
            }
            return(mobilePhone);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Are you an apple fangirl?");
            var isFangirl = Console.ReadLine() == "yes" ? true : false;
            ITechnologyAbstractFactory techFactory = null;

            if (isFangirl)
            {
                techFactory = new AppleFactory();
            }
            else
            {
                techFactory = new SamsungFactory();
            }
            IMobilePhone myphone  = techFactory.CreatePhone();
            ITablet      mytablet = techFactory.CreateTablet();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            string techType = Console.ReadLine();

            ITechnologyAbstractFactory abstractFactory = null;

            if (techType.ToLower() == "samsung")
            {
                abstractFactory = new SamsungFactory();
            }
            else if (techType.ToLower() == "apple")
            {
                abstractFactory = new AppleFactory();
            }

            IMobilePhone mobilePhone = abstractFactory.CreatePhone();
            ITablet      tablet      = abstractFactory.CreateTablet();

            Console.WriteLine(mobilePhone.GetType().Name);
            Console.WriteLine(tablet.GetType().Name);
        }
Exemplo n.º 7
0
 public MobileClient(IMobilePhone mobilePhone)
 {
     _normalPhone = mobilePhone.GetNormalPhone();
     _smartPhone  = mobilePhone.GetSmartPhone();
 }
Exemplo n.º 8
0
 public Human(IMobilePhone mobilePhone)
 {
     _mobilePhone = mobilePhone;
 }
Exemplo n.º 9
0
 public MobileClient(IMobilePhone factory)
 {
     smartPhone  = factory.GetSmartPhone();
     normalPhone = factory.GetNormalPhone();
 }
Exemplo n.º 10
0
        public static void InterfaceTest()
        {
            A a = new A(); //class A
            B b = new B(); //class B

            a.aTest();
            a.DialNumber();
            a.ReceiveCall();
            a.EndCall();
            b.aTest();
            b.DialNumber();
            b.ReceiveCall();
            b.EndCall();

            IMobilePhone iA = (IMobilePhone)a; //interface

            iA.DialNumber();
            iA.ReceiveCall();
            iA.EndCall();
            IMobilePhone iB = (IMobilePhone)b;

            iB.DialNumber();
            iB.ReceiveCall();
            iB.EndCall();


            MyFather f = new MyFather();
            MyMother m = new MyMother();

            f.Name = "James";
            m.Name = "Jennifer";

            Console.WriteLine("My {0} is {1}", f.ParentTitle(), f.Name);
            Console.WriteLine("My {0} is {1}", m.ParentTitle(), m.Name);

            Childer c = new Childer();

            c.Name       = "Sophy";
            c.title      = "Father";
            c.parentName = "Jame";
            Console.WriteLine("{2}'s {0} is {1}", c.ParentTitle(), c.ParentName(), c.Name);


            iFive obj = new OddEven(); //iFive (small) OddEven (bigger)

            obj.One();
            obj.Three();
            obj.Five();

            iEven obj1 = new OddEven();

            obj1.Two();
            obj1.Four();

            ILog log  = new ConsoleLog();
            ILog log1 = new FileLog();

            log.Log("sending log to console");
            log1.Log("write log to log.txt");

            infDemo.infDemoTest(); //public static method
        }
Exemplo n.º 11
0
 public MobileAbstractFactory(IMobilePhone factory)
 {
     smartPhone  = factory.GetSmartPhone();
     normalPhone = factory.GetNormalPhone();
 }
 public Person(IMobilePhone imobilephone)
 {
     _iMobilePhone = imobilephone;
 }
 public Client(IMobilePhone factory)
 {
     _smartPhone = factory.GetSmartPhone();
     _oldPhone   = factory.GetOldPhone();
 }
Exemplo n.º 14
0
 internal CMobilePhone(CItem parent, IMedDataSource dataSource) : base(parent, dataSource)
 {
     this.MobilePhone = (IMobilePhone)dataSource;
 }