static ISuperHero CreateHero(string HeroName) { Flash option1 = new Flash(375, HeroName, 30); SpiderMan option2 = new SpiderMan(450, HeroName, 21); SuperMan option3 = new SuperMan(1001, HeroName, 35); switch (HeroName) { case ("Flash"): return(option1); case ("SpiderMan"): return(option2); case ("Superman"): return(option3); default: return(null); } }
static void Main(string[] args) { Flash hero1 = new Flash(300, "Moshe", 31); SpiderMan hero2 = new SpiderMan(275, "Menashe", 25); SuperMan hero3 = new SuperMan(1000, "Jakob", 27); ISuperHero[] superHeroes = new ISuperHero[3]; superHeroes[0] = hero1; superHeroes[1] = hero2; superHeroes[2] = hero3; Console.WriteLine("Good Look SuperHeroes"); foreach (object HeroPerson in superHeroes) { IdentifyHero((ISuperHero)HeroPerson); ActivateHero((ISuperHero)HeroPerson); GetMoreHeroData((ISuperHero)HeroPerson); } Console.ReadLine(); }