Получавам 20/100 на почти решена задача и не знам как да я продължа
https://pastebin.com/hgtTVC1H
Create a program that organizes the daily feeding of animals. You need to keep information about animals, their daily food limit and the areas of the Wildlife Refuge they live in. You will be receiving lines with commands until you receive the "EndDay" message. There are two possible commands:
- "Add: {animalName}-{dailyFoodLimit}-{area}":
- Add the animal and its daily food limit to your records. It is guaranteed that the names of the animals are unique and there will never be animals with the same name. If it already exists, just increase the value of the daily food limit with the current one that is given.
- "Feed: {animalName}-{food}-{area}":
- Check if the animal exists and if it does, reduce its daily food limit with the given food for feeding. If its limit reaches 0 or less, the animal is considered successfully fed and you need to remove it from your records and print the following message:
- "{animalName} was successfully fed"
- Check if the animal exists and if it does, reduce its daily food limit with the given food for feeding. If its limit reaches 0 or less, the animal is considered successfully fed and you need to remove it from your records and print the following message:
You need to know the count of hungry animals there are left in each area in the end. If an animal has daily food limit above 0, it is considered hungry.
In the end, you have to print each animal with its daily food limit sorted in descending order by the daily food limit and then by its name in ascending order in the following format:
Animals:
{animalName} -> {dailyFoodLimit}g
{animalName} -> {dailyFoodLimit}g
Afterwards, print the areas with the count of animals, which are not fed in descending order by the count of animals. If an area has 0 hungry animals in it, don't print it. The output must be in the following format:
Areas with hungry animals:
{areaName} : {countOfUnfedAnimals}
{areaName} : {countOfUnfedAnimals}
Input / Constraints
- You will be receiving lines until you receive the "Last Info" command.
- The food comes in grams and is an integer number in the range [1...100000].
- The input will always be valid.
- There will never be a case, in which an animal is in two or more areas at the same time.
Output
- Print the appropriate message after the "Feed" command, if an animal is fed.
- Print the animals with their daily food limit in the format described above.
- Print the areas with the count of unfed animals in them in the format described above.
В момента не е достъпен judje но ако може просто да бъде пратено някакво примерно решение . Грешката ми е в тази част
'Afterwards, print the areas with the count of animals, which are not fed in descending order by the count of animals. If an area has 0 hungry animals in it, don't print it. The output must be in the following format: '
Не знам как на Area да инкрементирам когато някое животно остане гладно в конкретната зона . Всичко друго няма проблем , но ми даде на изпита 20/100
Input
Output
" {animal_name} -> {needed_food_quantity}g"
" {animal_name} -> {needed_food_quantity}g"
" {area_name}: {number_of_hungry_animals}"
" {area_name}: {number_of_hungry_animals}"
вход:
Заповядайте и входни данни !
(["Add: Adam-4500-ByTheCreek",
"Add: Maya-7600-WaterfallArea",
"Add: Maya-1230-WaterfallArea",
"Feed: Jamie-2000",
"EndDay"])
изход:
Animals:
Adam -> 4500g
Maya -> 8830g
Areas with hungry animals:
ByTheCreek: 1
WaterfallArea: 1