Example #1
0
        static void Main(string[] args)
        {
            // Create price watch for iPhone and attach restaurants that buy carrots from suppliers.
            var iphone = new Iphone(50000);

            iphone.SubscribePriceAlert(new Customer("*****@*****.**", 45000));
            iphone.SubscribePriceAlert(new Customer("*****@*****.**", 40000));
            iphone.SubscribePriceAlert(new Customer("*****@*****.**", 42000));

            var ipad = new Ipad(40000);

            ipad.SubscribePriceAlert(new Customer("*****@*****.**", 30000));
            ipad.SubscribePriceAlert(new Customer("*****@*****.**", 10000));

            //Adding subscriber for back in Stock alert
            ipad.SubscribeStockAlert(new Customer("*****@*****.**", true));
            ipad.SubscribeStockAlert(new Customer("*****@*****.**", false));
            ipad.SubscribeStockAlert(new Customer("*****@*****.**", true));


            //-----Actions being performed by admin in admin section ---------
            AdministratorAcitivity(iphone, ipad);


            Console.ReadKey();
        }
    static void Main(string[] args)
    {
        Demo   d  = new Demo();
        Iphone i1 = (Iphone)d;

        i1.Money();
        ((Ipen)i1).Price();
        Console.ReadKey();
    }
Example #3
0
        static void Main(string[] args)
        {
            Iphone iphone = new Iphone();

            iphone.Fiyat();

            Samsung samsung = new Samsung();

            samsung.Fiyat();
        }
Example #4
0
        /// <summary>
        /// Actions being performed by admin in admin section
        /// </summary>
        private static void AdministratorAcitivity(Iphone iphone, Ipad ipad)
        {
            //// Fluctuating prices will notify subscribing customer for Iphone
            iphone.Priced = 44000;

            //// Fluctuating prices will notify subscribing customer for Ipad
            ipad.Priced = 25000;

            //ipad is back in stock now so it will notify its subscriber
            ipad.IsInStock = true;
        }
Example #5
0
        static void Main(string[] args)
        {
            Galaxy s8 = new Galaxy("s8", 100, "Sprint", "DING DING DINGADONGDINGDING");

            s8.DisplayInfo();
            Console.WriteLine(s8.Ring());
            Console.WriteLine(s8.Unlock());
            Iphone x = new Iphone("x", 5, "at&t", "MARIMBA");

            x.DisplayInfo();
            Console.WriteLine(x.Ring());
            Console.WriteLine(x.Unlock());
        }
Example #6
0
        static void Main(string[] args)
        {
            ISmartphone ismartphone;


            ismartphone = new Iphone();
            ismartphone.Merk();

            Console.WriteLine();
            ismartphone = new Samsung();
            ismartphone.Merk();
            Console.ReadKey();
        }
Example #7
0
        public void Run()
        {
            #region Get Delivery cost values from config.

            var costPerDelivery = _config.GetValue <double>("Delivery:CostPerDelivery");
            var costPerProduct  = _config.GetValue <double>("Delivery:CostPerProduct");
            var fixedCost       = _config.GetValue <double>("Delivery:FixedCost");

            #endregion

            #region Category and product creation

            var computerCategory = new Category.Category("Computer");
            var phoneCategory    = new Category.Category("Phone");

            var ipone   = new Iphone(7500, phoneCategory);
            var macbook = new Macbook(18500, computerCategory);

            #endregion

            #region Shopping cart creation

            IShoppingCart cart = new Cart.ShoppingCart(new DeliveryCostCalculator(costPerDelivery, costPerProduct, fixedCost));
            cart.AddItem(ipone, 10);
            cart.AddItem(macbook, 5);

            #endregion

            #region Get campaign type from CampaignFactory with CampaignTypes enum.

            CampaignFactory campaignFactory = new CampaignFactory();
            var             campaign2       = campaignFactory.Get(computerCategory, 1500, 1, CampaignTypes.Amount);
            var             campaign3       = campaignFactory.Get(phoneCategory, 2, 1, CampaignTypes.Rate);

            #endregion

            #region Apply first campaign discount then coupon

            cart.ApplyDiscounts(campaign2, campaign3);

            CouponFactory couponFactory = new CouponFactory();
            var           coupon        = couponFactory.Get(500, 150, CouponTypes.Amount);

            cart.ApplyCoupon(coupon);

            #endregion

            Console.WriteLine(cart.Print());

            Console.ReadLine();
        }
Example #8
0
        static void Main(string[] args)
        {
            Iphone iphone = new Iphone();

            iphone.Fiyat = 4000;
            iphone.Bilgiler();

            Console.WriteLine("----");

            Samsung samsung = new Samsung();

            samsung.Fiyat = 2000;
            samsung.Bilgiler();

            Console.ReadLine();
        }
Example #9
0
        public static void Executar()
        {
            Celular c1 = new Iphone();

            c1.Assistente();


            var celulares = new List <Celular>
            {
                new Iphone(),
                new Motorola()
            };

            foreach (var celular in celulares)
            {
                Console.WriteLine(celular.Assistente());
            }
        }
Example #10
0
        private static void PerformAdapterPattern()
        {
            Android android = new Android();

            Iphone iPhone = new Iphone();

            AdapterService.RechargeMicroUsbPhone(android);
            Console.WriteLine("Recharging android with MicroUsb ...");

            AdapterService.RechargeLightningPhone(iPhone);
            Console.WriteLine("Recharging iPhone with Lightning ...");

            LightningToMircroUsbAdapter lightingPhoneAdaptee = new LightningToMircroUsbAdapter(iPhone);

            AdapterService.RechargeMicroUsbPhone(lightingPhoneAdaptee);
            Console.WriteLine("Recharging iPhone with MicroUsb");

            Console.ReadKey();
        }
Example #11
0
        public static void checkForPhone(Iphone iphone)
        {
            var client  = new RestClient(iphone.Url);
            var request = new RestRequest(Method.GET);

            IRestResponse response    = client.Execute(request);
            var           content     = response.Content; // raw content as string
            var           appleObject = JsonConvert.DeserializeObject <AppleResponse>(content);

            if (appleObject.Body.PickupMessage.NotAvailableNearOneStore != "Not available today at the nearest store.")
            {
                // Beep infinitely.
                for (int i = 0; i < int.MaxValue; i++)
                {
                    Console.Beep();
                }
            }

            Console.WriteLine("None available");
        }
Example #12
0
 public static void startMain1()
 {
     Student st = new Student()
     {
         Id = 123, Name = "张三"
     };
     {
         BasePhone mi = new Mi();
         st.PlayPhone(mi);
     }
     {
         IExcent iphone = new Iphone();
         //st.PlayPhone(iphone);
     }
     {
         BasePhone b = new Iphone();
         b.Show();        //普通方法是由编译时类型决定  调用父类
         b.ShowVirtual(); //虚方法是由运行时类型决定的 调用子类
         b.Call();        //抽象也是 调用子类
     }
 }
Example #13
0
        static void Main(string[] args)
        {
            //IOC思想:
            //上层模块不依赖于下层模块 两者都依赖于抽象
            //抽象不依赖于细节 细节依赖于抽象


            //上层模块是依赖于抽象 但是这里抽象依赖于细节了
            //IDbInterface db = new MSSQL();

            //Unity相当于是一个类的容器 工厂
            //IUnityContainer container = new UnityContainer();
            ////注册类型
            ////container.RegisterType<IMSSQL,MSSQL>();
            //container.RegisterType<IOracle, Oracle>();
            ////注册实例
            //container.RegisterInstance<IMSSQL>(new MSSQL());
            //var mssql= container.Resolve<IMSSQL>();
            //Console.WriteLine(mssql.Insert());



            //实现IOC
            IUnityContainer container = new UnityContainer();

            container.RegisterType <IHeadphone, Headphone>();
            container.RegisterType <IMicrophone, Microphone>();
            container.RegisterType <IPower, Power>();
            container.RegisterType <Iphone, ApplePhone>();

            Iphone applePhone = container.Resolve <Iphone>();

            Console.WriteLine($"Phone.headphone==null?{applePhone.iHeadphone == null}");
            Console.WriteLine($"Phone.microphone==null?{applePhone.iMicrophone == null}");
            Console.WriteLine($"Phone.power==null?{applePhone.iPower == null}");
            Console.ReadKey();
        }
Example #14
0
 public userphone(Iphone iphone)
 {
     _phone = iphone;
 }
Example #15
0
        public void ProductIphone_ShouldArgumentNullException_WhenTitleIsNull(string title)
        {
            var iphone = new Iphone(7500, phoneCategory, title);

            Assert.Throws <ArgumentNullException>(() => iphone.ProductTitle);
        }
Example #16
0
 public PhoneUser(Iphone phone)
 {
     _phone = phone;
 }
Example #17
0
        public void ProductIphone_ShouldArgumentOutOfRangeException_WhenPriceIsLessThanOrEqualZero(double price)
        {
            var iphone = new Iphone(price, phoneCategory);

            Assert.Throws <ArgumentOutOfRangeException>(() => iphone.Price);
        }
Example #18
0
        public void ONLYRESET(Iphone iphone, string[] apps)
        {
            Random rnd = new Random();
            string commandFile = "reset-phone";// "commands\\" + apps[rnd.Next(0, apps.Length)];
            iphone.OpenNumber += 1;
            //if (iphone.OpenNumber % Config.iConfig.RoundResetIDFV == 0)
            //{
            //    //reset idfa,idfv
            //    commandFile = commandFile + "-reset";
            //}
            //else if (iphone.OpenNumber % Config.iConfig.RoundClickAd == 0)
            //{
            //    commandFile = "click-ad";
            //}
            Process p = new Process();
            OpenPutty(Config.iConfig.DefaultIP + iphone.IP, commandFile + ".txt", ref p);
            System.Threading.Thread.Sleep(Config.iConfig.WaitKillPutty);
            //Process[] p = Process.GetProcessesByName("putty");
            try
            {
                p.Kill();

            }
            catch
            {
            }
            ONLYRESET(iphone, apps);
        }
Example #19
0
        private void ListIPCopy_Click(object sender, EventArgs e)
        {
            BindingList<Iphone> listVNC = new BindingList<Iphone>();
            string[] listStr = txtListIP.Text.Split('\n');

            foreach (string item in listStr)
            {
                string str = item.Replace("\r", "");//System.Environment.NewLine
                Iphone v = new Iphone();
                v.IP = str;
                v.Select = true;
                listVNC.Add(v);
            }
            Utility.SaveListIP(listVNC);
            LoadFirst();
        }
Example #20
0
        public void openApp(Iphone iphone, string[] apps)
        {
            Random rnd = new Random();
            string commandFile = "commands\\" + apps[rnd.Next(0, apps.Length)];
            iphone.OpenNumber += 1;
            if (iphone.OpenNumber % Config.iConfig.RoundResetIDFV == 0)
            {
                //reset idfa,idfv
                commandFile = commandFile + "-reset";
            }
            else if (iphone.OpenNumber % Config.iConfig.RoundClickAd == 0)
            {
                commandFile = "click-ad";
            }
            Process p = new Process();
            OpenPutty(Config.iConfig.DefaultIP + iphone.IP, commandFile + ".txt", ref p);
            System.Threading.Thread.Sleep(Config.iConfig.WaitKillPutty);
            //Process[] p = Process.GetProcessesByName("putty");
            try
            {
                p.Kill();
                //if (p != null)
                //{
                //    foreach (Process item in p)
                //    {

                //        //item.Kill();
                //    }
                //}
            }
            catch
            {
            }
            openApp(iphone, apps);
        }
Example #21
0
 public static void Executar()
 {
     Celular iphoneX = new Iphone();
 }