static void Main(string[] args) { /* * Factory Method * * creational grubuna ait, aynı arayüzü kullanan nesnelerin üretiminden sorumlu tasarım desenidir. */ Creater cr = new Creater(); MobileApplication MobileAndroid = cr.FactoryMethod(AllMobileOs.android); MobileApplication MobileIphone = cr.FactoryMethod(AllMobileOs.iphone); MobileApplication MobileWindows = cr.FactoryMethod(AllMobileOs.windows); MobileIphone.Platform(); MobileWindows.Platform(); MobileAndroid.Platform(); Console.ReadKey(); }
public MobileApplication FactoryMethod(AllMobileOs osType)//iphone { MobileApplication ma = null; switch (osType) { case AllMobileOs.android: ma = new AndroidOS(); break; case AllMobileOs.iphone: ma = new IPhoneOS(); break; case AllMobileOs.windows: ma = new WindowsOS(); break; } return(ma); }