Exemple #1
0
        static void Main(string[] args)
        {
            SendOrder _sendOrder = new SendDairyFreeOrder();

            _sendOrder._restaurant = new DinerOrders();
            _sendOrder.Send();

            _sendOrder._restaurant = new FancyRestaurantOrders();
            _sendOrder.Send();

            _sendOrder             = new SendGlutenFreeOrder();
            _sendOrder._restaurant = new DinerOrders();
            _sendOrder.Send();

            _sendOrder._restaurant = new FancyRestaurantOrders();
            _sendOrder.Send();

            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.Write("1. Мост\n2. Фасад\n3. Компоновщик \nВведите число:");
            string str       = Console.ReadLine();
            int    switchVar = Convert.ToInt32(str);

            switch (switchVar)
            {
            case 1:
            {
                SendOrder sendOrder = new SendSpicyPizzaOrder();
                sendOrder.restaurant = new DinerOrders();
                sendOrder.Send();

                sendOrder.restaurant = new FancyRestaurantOrders();
                sendOrder.Send();

                sendOrder            = new SendGlutenFreeOrder();
                sendOrder.restaurant = new DinerOrders();
                sendOrder.Send();

                sendOrder.restaurant = new FancyRestaurantOrders();
                sendOrder.Send();

                Console.ReadKey();
                break;
            }

            case 2:
            {
                Console.WriteLine("Заказы пиццы\n");

                var facadeForClient = new RestaurantFacade();

                facadeForClient.GetPepperoniPizza();
                facadeForClient.GetPizzaMargherita();

                Console.WriteLine("\nЗаказы основы\n");

                facadeForClient.GetDarkBread();
                facadeForClient.GetWhiteBreadWithSesame();

                Console.ReadKey();
                break;
            }

            case 3:
            {
                Client client = new Client();

                Content content = new Content();
                Console.WriteLine("1:");
                client.ClientCode(content);

                Composite tree = new Composite();
                Composite box1 = new Composite();
                box1.Add(new Content());
                box1.Add(new Content());
                Composite box2 = new Composite();
                box2.Add(new Content());
                tree.Add(box1);
                tree.Add(box2);
                Console.WriteLine("2:");
                client.ClientCode(tree);

                Console.Write("3:\n");
                client.ClientCode2(tree, content);

                Console.ReadKey();
                break;
            }
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // With the Bridge Design Pattern you create 2 layers of abstraction
            // In this example I'll have an abstract class representing
            // different types of devices. I also have an abstract class
            // that will represent different types of remote controls

            #region Restaurant
            SendOrder _sendOrder = new SendDairyFreeOrder();

            _sendOrder._restaurant = new DinerOrders();
            _sendOrder.Send();

            _sendOrder._restaurant = new FancyRestaurantOrders();
            _sendOrder.Send();

            _sendOrder = new SendGlutenFreeOrder();

            _sendOrder._restaurant = new DinerOrders();
            _sendOrder.Send();

            _sendOrder._restaurant = new FancyRestaurantOrders();
            _sendOrder.Send();
            #endregion

            #region Entertainment

            // This allows me to use an infinite variety of devices and remotes

            RemoteButton theTV = new TVRemoteMute(new TVDevice(1, 200));

            RemoteButton theTV2 = new TVRemotePause(new TVDevice(1, 200));

            // HOMEWORK --------------

            RemoteButton theDVD = new DVDRemote(new DVDDevice(1, 14));

            // -----------------------

            Console.WriteLine("Test TV with Mute");

            theTV.buttonFivePressed();
            theTV.buttonSixPressed();
            theTV.buttonNinePressed();

            Console.WriteLine("\nTest TV with Pause");

            theTV2.buttonFivePressed();
            theTV2.buttonSixPressed();
            theTV2.buttonNinePressed();
            theTV2.deviceFeedback();

            // HOMEWORK
            Console.WriteLine("\nTest DVD");

            theDVD.buttonFivePressed();
            theDVD.buttonSixPressed();
            theDVD.buttonNinePressed();
            theDVD.buttonNinePressed();
            #endregion


            Console.ReadKey();
        }