static void Main(string[] args)
        {
            IPhoneFactory samsungFactory = new SamsungFactory();
            IPhoneFactory nokiaFactory   = new NokiaFactory();

            var samsungSmartFactory = samsungFactory.GetSmartPhone();
            var samsungDumbPhone    = samsungFactory.GetDumbPhone();
            var nokiaSmartPhone     = nokiaFactory.GetSmartPhone();
            var nokiaDumbPhone      = nokiaFactory.GetSmartPhone();

            samsungSmartFactory.DoSomething();
            samsungDumbPhone.DoSomething();

            // Dvata metoda trqbva da varvqt zaedno v IPhoneFactory
            // Taka vsqka konkretna fabrika trqbva da sazdava i smartphones i dumbphone
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var samsungFactory = new SamsungFactory();
            var samsungPhone   = samsungFactory.GetPhone();
            var samsungTablet  = samsungFactory.GetTablet();

            Console.WriteLine("Samsung factory:");
            Console.WriteLine($"Phone - {samsungPhone.Name}\nTablet - {samsungTablet.Name}");

            var appleFactory = new AppleFactory();
            var applePhone   = appleFactory.GetPhone();
            var appleTablet  = appleFactory.GetTablet();

            Console.WriteLine("Apple factory:");
            Console.WriteLine($"Phone - {applePhone.Name}\nTablet - {appleTablet.Name}");
        }
Beispiel #3
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();
        }
Beispiel #4
0
 PhoneTypeChecker(Manufactures manu)
 {
     if (manu == Manufactures.Samsung)
     {
         SamsungFactory s = new SamsungFactory();
         factory = s;
         CheckProducts(factory);
     }
     else if (manu == Manufactures.HTC)
     {
         HTCFactory htc = new HTCFactory();
         factory = htc;
         CheckProducts(factory);
     }
     else if (manu == Manufactures.Nokia)
     {
         NokiaFactory n = new NokiaFactory();
         factory = n;
         CheckProducts(factory);
     }
 }