Пример #1
0
        static void Main()
        {
            BackPackFactory factory = new BackPackFactory();
            List <string>   people  = new List <string>
            {
                "Peter",
                "Hans",
                "Aleh",
                "Jhon",
                "Nick"
            };
            string typeBackPack        = "city";
            List <ConsoleColor> colors = new List <ConsoleColor> {
                ConsoleColor.Black, ConsoleColor.Blue, ConsoleColor.DarkGreen
            };

            foreach (string person in people)
            {
                foreach (ConsoleColor color in colors)
                {
                    BackPack backPack = factory.GetBackPack(typeBackPack);
                    typeBackPack = typeBackPack == "city"?"mountain": "city";
                    backPack.PutOn(color, person);
                }
            }
            Console.ReadKey();
        }
Пример #2
0
        public BackPack GetBackPack(string key)
        {
            BackPack result = null;

            if (_backPacks.ContainsKey(key))
            {
                result = _backPacks[key];
            }
            return(result);
        }