public void Run() { int n = int.Parse(Console.ReadLine()); while (n > 0) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); try { BaseHero hero = heroFactory.CreateHero(heroName, heroType); heroes.Add(hero); n--; } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } int bossPower = int.Parse(Console.ReadLine()); foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); } if (heroes.Sum(x => x.Power) >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
private void CreateAllHeroes(List <BaseHero> heroes) { int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); heroes.Add(heroFactory.CreateHero(heroName, heroType)); } }
private void CreateHeroes() { int n = int.Parse(this.reader.ReadLine()); while (this.heroes.Count != n) { string heroName = this.reader.ReadLine(); string heroType = this.reader.ReadLine(); try { BaseHero hero = heroFactory.CreateHero(heroType, heroName); this.heroes.Add(hero); } catch (InvalidHeroTypeException iht) { this.writer.WriteLine(iht.Message); } } }
private void CreateRaidGroup() { int count = int.Parse(this.reader.ReadLine()); while (count > this.heroes.Count) { var name = this.reader.ReadLine(); var type = this.reader.ReadLine(); try { BaseHero hero = heroFactory.CreateHero(type, name); heroes.Add(hero); } catch (Exception msg) { this.writer.WriteLine(msg.Message); } } }
public void Run() { int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); try { if (heroType == "Druid" || heroType == "Paladin" || heroType == "Rogue" || heroType == "Warrior") { hero = heroFactory.CreateHero(heroName, heroType); if (hero != null) { raid.Add(hero); } } } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } } int bossPower = int.Parse(Console.ReadLine()); int herousPower = raid.Sum(x => x.Power); CastAbilitiesAll(); if (herousPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
public void Run() { int n = int.Parse(Console.ReadLine()); HeroFactory factory = new HeroFactory(); BaseHero hero = null; int count = 0; while (count < n) { var heroname = Console.ReadLine(); var herotype = Console.ReadLine(); try { hero = factory.CreateHero(heroname, herotype); heroes.Add(hero); count++; } catch (Exception e) { Console.WriteLine(e.Message); } } int bosshealth = int.Parse(Console.ReadLine()); int totalpower = 0; foreach (var item in heroes) { Console.WriteLine(item.CastAbility()); totalpower += item.Power; } if (totalpower >= bosshealth) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
public void Run() { int heroesCont = int.Parse(Console.ReadLine()); while (heroesCont != heroes.Count) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); BaseHero hero = null; try { hero = HeroFactory.CreateHero(heroName, heroType); heroes.Add(hero); } catch (IvalidWariorException ex) { Console.WriteLine(ex.Message); } } int bossPower = int.Parse(Console.ReadLine()); foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); } int powerSum = heroes.Sum(x => x.Power); if (powerSum >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }