Beispiel #1
0
        static void Main(string[] args)
        {
            Flash     evgeni = new Flash("Evgeni", 3, 120.0f);
            SpiderMan pavel  = new SpiderMan("Pavel", 4, 10.1f);
            SuperMan  alex   = new SuperMan("Alex", 30, 400);

            ISuperHero[] superHeroes = new ISuperHero[] { evgeni, pavel, alex };

            foreach (ISuperHero superHero in superHeroes)
            {
                ActivateHero(superHero);
            }
        }
Beispiel #2
0
        static void GetMoreHeroData(ISuperHero superHero)
        {
            Flash flash = superHero as Flash;

            if (superHero != null)
            {
                Console.WriteLine($"Additional information: .{flash.Voltage}");
            }
            SpiderMan spiderMan = superHero as SpiderMan;

            if (superHero != null)
            {
                Console.WriteLine($"Additional information: .{spiderMan.Speed}");
            }
            SuperMan superMan = superHero as SuperMan;

            if (superHero != null)
            {
                Console.WriteLine($"Additional information: .{superMan.WebLeft}");
            }
        }