Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var key = new ConsoleKeyInfo();

            while (!(key.Key == ConsoleKey.D4 || key.Key == ConsoleKey.NumPad4))
            {
                Logistics logistics = null;

                key = ShowMenu();
                switch (key.Key)
                {
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:
                    logistics = new RoadLogistic();
                    break;

                case ConsoleKey.D2:
                case ConsoleKey.NumPad2:
                    logistics = new SeaLogistic();
                    break;

                case ConsoleKey.D3:
                case ConsoleKey.NumPad3:
                    break;
                }

                if (logistics != null)
                {
                    Console.WriteLine();
                    var transport = logistics.CreateTransport();
                    Console.WriteLine(transport.Deliver());
                    Wait();
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Logistic logistic = new RoadLogistic();

            Transport transport1 = logistic.CreateTransport();

            transport1.Deliver();                               //  Доставка на грузовике

            logistic = new SeaLogistic();
            Transport transport2 = logistic.CreateTransport();

            transport2.Deliver();                               //  Доставка на корабле
        }