Exemple #1
0
        public ClothesStore GetQuantity(char key)
        {
            ClothesStore clothesQuant = null;

            if (clothes.ContainsKey(key))
            {
                clothesQuant = clothes[key];
            }
            else
            {
                switch (key)
                {
                case 'W':
                    clothesQuant = new WomenClothes();
                    break;

                case 'M':
                    clothesQuant = new ManClothes();
                    break;

                case 'K':
                    clothesQuant = new KidsClothes();
                    break;
                }
                clothes.Add(key, clothesQuant);
            }
            return(clothesQuant);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Please add to cart what do you want to buy!");
            Console.WriteLine("Use characters W for women clothes, K for kids clothes, M for man clothes with no spaces.");
            Console.WriteLine("You can add more than one product. (Ex. WMKKWM)");

            ClothesFactory factory = new ClothesFactory();
            int            count   = 0;
            var            order   = Console.ReadLine();

            char[] chars     = order.ToCharArray();
            int    countItem = 0;


            foreach (char c in chars)
            {
                count++;
                ClothesStore store = factory.GetClothes(c);
                store.ViewClothes(count);
            }

            foreach (char c in chars)
            {
                countItem++;
                ClothesStore store = factory.GetQuantity(c);
                store.SellItem(countItem);
            }

            Console.ReadLine();
        }