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 }
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); } }