+ Нов въпрос
petur_stoqnov 13 Точки

## Battle Manager - Programming Fundamentals Final Exam - 03 August 2019 Group 2

Здравейте колеги,

Моля за помощ, дава ми 91/100 и не знам къде греша.

Условие:

Battle Manager

Create a program that manages battles. You need to keep information about people, the health and energy they have. You will be receiving lines with commands until you receive the "Results" command. There are three possible commands:

• Add the person, his/her health and energy to your records. If person with the given name already exists, just increase the health of the person with the current one that is given.
• "Attack:{attackerName}:{defenderName}:{damage}":
• Check if both people exist and if they do, reduce the defender’s health with the damage given. If the defender’s health reaches 0 or less, the person is disqualified, and you need to remove him/her from your records and print the following message:
• "{defenderName} was disqualified!"
• You also have to reduce the attacker’s energy by 1. If it reaches 0, he/she is disqualified, and you need to remove him/her from your records and print the following message:
• "{attackerName} was disqualified!"
• Delete all records of the given user, if he exists. If "All" is given as username - delete all records you have.

In the end, you have to print the count of people left, each person with his/her health and energy sorted in descending order by the health and then by their name in ascending order in the following format:

People count: {count}

{personName} - {health} - {energy}

{personName} - {health} - {energy}

## Input

• You will be receiving lines until you receive the "Results" command.
• The health is an integer number in the range [1...100000].
• The energy is an integer number in the range [1...100].
• The input will always be valid.

## Output

• Print the appropriate message after the "Attack" command, if someone is disqualified.
• Print the people with their health and energy in the format described above.

## Examples

Тагове:
0
JSuser 220 Точки

Здравей,

Изтрий 53-ти ред:

treeMap.get(name).setEnergy(energy + treeMap.get(name).getEnergy());  - не трябва да увеличаваш енергията.

Ще ти даде 100/100!

0
krumkuzmov 5 Точки

Благодаря и аз за отговора! Много беше полезно :) трябва да се чете внимателно, както ни напомнят постоянно.

0
petur_stoqnov 13 Точки

Благодаря ти и от мен, че си отделил време да решиш проблема :)

0