Advertisement
Guest User

Untitled

a guest
Nov 17th, 2021
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Raiding
  5. {
  6.     public class Program
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             List<BaseHero> raidGroup = new List<BaseHero>();
  11.  
  12.             int n = int.Parse(Console.ReadLine());
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 string heroName = Console.ReadLine();
  17.                 string heroType = Console.ReadLine();
  18.  
  19.                 BaseHero hero = null;
  20.  
  21.                 if (heroType == nameof(Druid))
  22.                 {
  23.                     hero = new Druid(heroName);
  24.                 }
  25.                 else if (heroType == nameof(Paladin))
  26.                 {
  27.                     hero = new Paladin(heroName);
  28.                 }
  29.                 else if (heroType == nameof(Rogue))
  30.                 {
  31.                     hero = new Rogue(heroName);
  32.                 }
  33.                 else if (heroType == nameof(Warrior))
  34.                 {
  35.                     hero = new Warrior(heroName);
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine("Invalid hero!");
  40.                     i--;    //HERE!
  41.                     continue;
  42.                 }
  43.  
  44.                 raidGroup.Add(hero);
  45.             }
  46.  
  47.             int bossPower = int.Parse(Console.ReadLine());
  48.             int heroTotalPower = 0;
  49.  
  50.             foreach (var hero in raidGroup)
  51.             {
  52.                 Console.WriteLine(hero.CastAbility());
  53.                 heroTotalPower += hero.Power;
  54.             }
  55.  
  56.             if (heroTotalPower >= bossPower)
  57.             {
  58.                 Console.WriteLine("Victory!");
  59.             }
  60.             else
  61.             {
  62.                 Console.WriteLine("Defeat...");
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement