예제 #1
0
        static void Main(string[] args)
        {
            Product tShirt = new TShirt(6, "PULL");

            tShirt.AvailableColors = new List <ConsoleColor>()
            {
                ConsoleColor.Blue, ConsoleColor.Black
            };
            tShirt.AvailableSizes = new List <int>()
            {
                41, 42
            };
            tShirt.Quantity = 1;

            Product dressShirt = new TShirt(8, "POLO");

            dressShirt.AvailableColors = new List <ConsoleColor>()
            {
                ConsoleColor.Cyan, ConsoleColor.DarkBlue
            };
            dressShirt.AvailableSizes = new List <int>()
            {
                40, 41, 42
            };
            dressShirt.Quantity = 1;

            Vendor vendor = new Vendor();

            tShirt.SizeSelected  = 41;
            tShirt.ColorSelected = ConsoleColor.Blue;

            vendor.Order(tShirt);

            dressShirt.SizeSelected  = 41;
            dressShirt.ColorSelected = ConsoleColor.Blue;

            vendor.Order(dressShirt);

            vendor.SetRetailPrice(tShirt, 12);
            vendor.SetRetailPrice(dressShirt, 20);

            vendor.Sell();
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <Product> products = new List <Product>();

            var someClothing = new Clothing()
            {
                Name  = "Fresh pants",
                Brand = "Benetton",
                Size  = ClothingSize.Medium,
                Color = "Ligh green",
                Price = 180
            };
            var niceShirt = new Shirt()
            {
                Name       = "Elegant shirt",
                Brand      = "Polo",
                Size       = ClothingSize.Small,
                Color      = "Dark red",
                ButtonType = "Mate rounded buttons",
                Price      = 245
            };
            var niceTShirt = new TShirt()
            {
                Name     = "Casual Tshirt",
                Brand    = "Toto",
                Size     = ClothingSize.ExtraLarge,
                Color    = "Blue",
                NeckType = "V neck",
                Price    = 100
            };
            var someAccesorie = new Accesorie()
            {
                Name     = "Wooden wrist band",
                Brand    = "Some brand",
                Color    = "Dark brown",
                Material = "Wood",
                Price    = 95
            };
            var goldenNecklace = new Necklace()
            {
                Name            = "Golden fantasy necklace",
                Brand           = "Jewel",
                Color           = "Golden",
                Material        = "Gold",
                DetailsMaterial = "Fantasy",
                Price           = 300
            };

            products.Add(someClothing);
            products.Add(niceShirt);
            products.Add(niceTShirt);
            products.Add(someAccesorie);
            products.Add(goldenNecklace);

            //Liskovs Polimorfism example
            var index = 1;

            foreach (Product product in products)
            {
                Console.WriteLine($"----------PRODUCT #{index} ({product.Name})----------");
                product.TryOn();//Each class implements this method differently
                Console.WriteLine();
                index++;
            }
        }