Esempio n. 1
0
 static void IdentifyHero(ISuperHero Heroes)
 {
     if (Heroes.GetType() == typeof(Flash))
     {
         Console.WriteLine($"Flash detected");
     }
     if (Heroes.GetType() == typeof(SpiderMan))
     {
         Console.WriteLine($"SpiderMan detected");
     }
     if (Heroes.GetType() == typeof(SuperMan))
     {
         Console.WriteLine($"SuperMan detected");
     }
 }
Esempio n. 2
0
        static void IdentifyHero(ISuperHero seHero)
        {
            if (seHero.GetType() == typeof(Flash))
            {
                Console.WriteLine($"Flash detected");
            }

            if (seHero.GetType() == typeof(SuperMan))
            {
                Console.WriteLine("Superman detected");
            }
            else if (seHero.GetType() == typeof(SpiderMan))
            {
                Console.WriteLine($"Spiderman detected");
            }
        }
Esempio n. 3
0
        static void CreateHero(ISuperHero Heroes)
        {
            if (Heroes.GetType() == typeof(Flash))
            {
                Flash flash1 = new Flash("New Flash", 20, 600);
                Console.WriteLine("New object");
                Console.WriteLine(flash1.ToString());
            }

            if (Heroes.GetType() == typeof(SuperMan))
            {
                SuperMan super1 = new SuperMan("New Clark", 33, "270");
                Console.WriteLine("New object");
                Console.WriteLine(super1.ToString());
            }
            else if (Heroes.GetType() == typeof(SpiderMan))
            {
                SpiderMan spider1 = new SpiderMan("New Spider", 21, 200);
                Console.WriteLine("New object");
                Console.WriteLine(spider1.ToString());
            }
        }
Esempio n. 4
0
        static void CreateHero(ISuperHero seHero)
        {
            if (seHero.GetType() == typeof(Flash))
            {
                Flash flash1 = new Flash("New Flash", 18, 480);
                Console.WriteLine("*** New object **");
                Console.WriteLine(flash1.ToString());
            }

            if (seHero.GetType() == typeof(SuperMan))
            {
                SuperMan super1 = new SuperMan("New Clark", 58, "120");
                Console.WriteLine("*** New object **");
                Console.WriteLine(super1.ToString());
            }
            else if (seHero.GetType() == typeof(SpiderMan))
            {
                SpiderMan spider1 = new SpiderMan("New Spider", 44, 100);
                Console.WriteLine("*** New object **");
                Console.WriteLine(spider1.ToString());
            }
        }
Esempio n. 5
0
 static void IdentyHero(ISuperHero hero)
 {
     if (hero is SuperMan)
     {
         Console.WriteLine("This is superman");
     }
     else if (hero is SpiderMan)
     {
         Console.WriteLine("This is Spiderman");
     }
     else if (hero is Flash)
     {
         Console.WriteLine("This is Flash");
     }
     else
     {
         Console.WriteLine($"This : {hero.GetType()}");
     }
 }
Esempio n. 6
0
 static void IdentifyHero(ISuperHero hero)
 {
     if (hero is SuperMan)
     {
         Console.WriteLine("Got superman!!");
     }
     else if (hero is SpiderMan)
     {
         Console.WriteLine("Spiderman detected!");
     }
     else if (hero is Flash)
     {
         Console.WriteLine("Flash here!");
     }
     else
     {
         Console.WriteLine($"Got : {hero.GetType()}");
     }
 }
Esempio n. 7
0
 static void ActivateSuperhero(ISuperHero Hero)
 {
     Console.WriteLine($"{Hero.GetType()} Powers activated!");
 }