private WizardCostume CreateCostume()
        {
            var costume = new WizardCostume();

            costume.AddArticle(CreateHat("blue", "description", "hatty", true));
            costume.AddArticle(CreateRobe("blue", "description", "robey", true));
            costume.AddArticle(CreateWand("blue", "description", "wanda", Wand.eMaterialType.Glass));
            return(costume);
        }
Ejemplo n.º 2
0
        private static void TestCostume()
        {
            WizardCostume costume = new WizardCostume();
            Robe          robe    = new Robe();

            robe.Color               = "Blue";
            robe.Description         = "My first robe";
            robe.Name                = "Midday sky";
            robe.SupportInvisibility = false;
            costume.AddArticle(robe);

            Hat hat = new Hat();

            hat.Color       = "Silver";
            hat.Description = "My first hat";
            hat.Name        = "Sir pointy";
            hat.IsPointy    = true;
            costume.AddArticle(hat);

            Wand wand = new Wand();

            wand.Color       = "Chrome";
            wand.Description = "My first wand";
            wand.Name        = "Wanda";
            costume.AddArticle(wand);

            wand             = new Wand();
            wand.Color       = "Chrome";
            wand.Description = "My second wand";
            wand.Name        = "Wandy";
            costume.AddArticle(wand);

            Console.WriteLine($"Robe: {costume.Robe.Name}");
            Console.WriteLine($"Hat: {costume.Hat.Name}");
            var wands = costume.Wands;

            foreach (var item in wands)
            {
                Console.WriteLine($"Wand: {item.Name}");
            }

            Console.ReadKey();
        }
        private void DisplayCostumeDetail(WizardCostume costume)
        {
            Console.Clear();
            Console.WriteLine($"Costume Name: {costume.Name}");

            if (costume.Hat != null)
            {
                Console.WriteLine();
                DisplayColorTextLine(ConsoleColor.Yellow, "Hat");
                Console.WriteLine($"Name: {costume.Hat.Name}");
                Console.WriteLine($"Description: {costume.Hat.Description}");
                Console.WriteLine($"Color: {costume.Hat.Color}");
                string pointyMessage = costume.Hat.IsPointy ? "Yes" : "No";
                Console.WriteLine($"Pointy?: {pointyMessage}");
            }

            if (costume.Robe != null)
            {
                Console.WriteLine();
                DisplayColorTextLine(ConsoleColor.Yellow, "Robe");
                Console.WriteLine($"Name: {costume.Hat.Name}");
                Console.WriteLine($"Description: {costume.Hat.Description}");
                Console.WriteLine($"Color: {costume.Hat.Color}");
                string supportInvisibility = costume.Robe.SupportInvisibility ? "Yes" : "No";
                Console.WriteLine($"SupportsInvisibility?: {supportInvisibility}");
            }

            foreach (var wand in costume.Wands)
            {
                Console.WriteLine();
                DisplayColorTextLine(ConsoleColor.Yellow, "Wand");
                Console.WriteLine($"Name: {wand.Name}");
                Console.WriteLine($"Description: {wand.Description}");
                Console.WriteLine($"Color: {wand.Color}");
                Console.WriteLine($"Material: {wand.MaterialType.ToString()}");
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }