Пример #1
0
        public override void CallToTheFriends(string friendName, IPhysicalProtocol protocol)
        {
            if (CheckTheEnableDevice())
            {
                protocol = new GMSProtocol();
                protocol.ConnectionToTheNetwork(this);

                protocol.DisableFromTheNetwork(this);
            }
            else
            {
                Console.WriteLine("[Ощибка]: Телефон выключен!");
            }
        }
Пример #2
0
        private static void StartProgram()
        {
            Console.WriteLine("[function] TurnOnDevices(...)");

            Factory factoryPhone  = new FactoryPhone("Apple", "IT Corp. IPhone");
            Factory factoryLaptop = new FactoryLaptop("Apple", "IT Corp. Macbook");

            var phone  = factoryPhone.Create();
            var laptop = factoryLaptop.Create();

            LocalNetwork     network        = new LocalNetwork(phone, laptop);
            GMSProtocol      mobileProtocol = new GMSProtocol();
            EthernetProtocol laptopProtocol = new EthernetProtocol();

            Console.WriteLine();
            Console.WriteLine("[function] CallToTheFriends(...)");

            phone.CallToTheFriends("Bill", new GMSProtocol());
            laptop.CallToTheFriends("Walter", new EthernetProtocol());

            Console.WriteLine();
            Console.WriteLine("[function] ConnectionToTheNetwork(...)");

            mobileProtocol.ConnectionToTheNetwork(phone);
            laptopProtocol.ConnectionToTheNetwork(laptop);

            Console.WriteLine();
            Console.WriteLine("[function] SendMessage(...)");

            network.SendMessageToTheFirstDevice();
            network.SendMessageToTheSecondDevice();

            Console.WriteLine("Программа завершила свою работу!");

            Console.ReadLine();
        }