Problem 3. Raiding от Polymorphism - Exercise
Колеги,
помагайте. Проверих всичко 3 пъти, нулевите тестове минават, а Judge гърми на два с Грешка по време на изпълнение.
Задачата е супер елементарна, няма какво да гръмне по време на изпълнение освен парсване и try - catch, но все пък не виждам къде бъркам.
Ито кода https://app.box.com/s/3zi39yz6hd6emjvbhl2h0h1cwry2mnlw
Благодаря предварително!
Условието на задачата:
Your task is to create a class hierarchy like the described below. The BaseHero class should be abstract.
- BaseHero – string Name, int Power, string CastAbility()
- Druid – power = 80
- Paladin – power = 100
- Rogue – power = 80
- Warrior – power = 100
Each hero should override the CastAbility() method:
Druid – "{Type} – {Name} healed for {Power}"
Paladin – "{Type} – {Name} healed for {Power}"
Rogue – "{Type} – {Name} hit for {Power} damage"
Warrior – "{Type} – {Name} hit for {Power} damage"
Now use the classes you created to form a raid group and defeat a boss. You will receive an integer N from the console. On the next lines you will receive {heroName} and {heroType} until you create N amount of heroes. If the hero type is invalid print: "Invalid hero!" and don’t add it to the raid group. After the raid group is formed you will receive an integer from the console which will be the boss’s power. Then each of the heroes in the raid group should cast his ability once. You should sum the power of all of the heroes and if the total power is greater or equal to the boss’s power you have defeated him and you should print:
"Victory!"
Else print:
"Defeat..."
Bonus*
Use the Factory Design pattern to instantiate the classes.
Constraints
You need to create heroes until you have N amount of valid heroes.
Example
Input |
Output |
3 Mike Paladin Josh Druid Scott Warrior 250 |
Paladin - Mike healed for 100 Druid - Josh healed for 80 Warrior - Scott hit for 100 damage Victory! |
2 Mike Warrior Tom Rogue 200 |
Warrior - Mike hit for 100 damage Rogue - Tom hit for 80 damage Defeat... |
Да това бе проблема. Вече е на 100/100.
Благодаря!
-_- 1 час се чудих и дебъгвах и няма грешка, а даваше 60/100..... Никога нямаше да го видя това.
Мерси, колега! Дяволът е в детайлите. :D