Exemplo n.º 1
0
        public static void PrintDetails(IMobileFactory mobileFactory)
        {
            IMobileOS           os            = mobileFactory.GetMobileOS();
            IMobileManufacturer brandOfMobile = mobileFactory.GetMobileManufacturer();

            Console.WriteLine($"Company Name : {brandOfMobile.CompanyDetails() } -- OS of Mobile : {os.OSDetails()}");
        }
Exemplo n.º 2
0
        public static void Test()
        {
            IMobileFactory factory = null;

            factory = new XiaomiFactory();
            factory.product();

            factory = new HuaweiFactory();
            factory.product();
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     try
     {
         MobileShop shop = new MobileShop();
         Console.Write("Enter mobile brand you are looking for : ");
         string         userChoiceOfBrand = Console.ReadLine();
         IMobileFactory mobileFactory     = shop.BuyMobile(userChoiceOfBrand);
         PrintDetails(mobileFactory);
     }catch (NoSuchMobileExcpetion ex)
     {
         Console.WriteLine(ex.Message);
     }
     Console.ReadLine();
 }