Wild ZOO, Ako някой даде идея, как да достъпя valueTo на ареаМапА, ще съм повече от благодарен, прилагам pasteBin, оградил съм в скобите проблема ... Благодаря https://pastebin.com/JtFXGun8
https://pastebin.com/JtFXGun8
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.
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 |
Add: Jamie-600-WaterfallArea Add: Maya-6570-WaterfallArea Add: Adam-4500-ByTheCreek Add: Bobbie-6570-WaterfallArea Feed: Jamie-2000 Feed: Adam-2000 Feed: Adam-2500 EndDay |
Jamie was successfully fed Adam was successfully fed Animals: Maya -> 6570g Bobbie -> 6570g Areas with hungry animals: WaterfallArea: 2 |
Hi
Wild Zoo - Pastebin.com
I had a quick look at your way. First problem is you have to look at row 31 and 32 , the check for the area map needs to be indipendent from the feedMap. For the Feed part just have a look at my code, hope it helps. Sorry for the english easier writing on it.
PS If you dont use approach with creating objects in my opinion to connect the 3 paramethers, the first map needs to have enbodied map as Value containing the food and area.