04. Teamwork Projects - Objects and Classes - More Exercise
Здравейте,
Имам затруднения със посочената задача, като не намирам къде точно бърквам в кода. Judge ми дава 83/100 като гърми Test #1.
Условие:
It's time for teamwork projects and you are responsible for making the teams. First you will receive an integer - the count of the teams you will have to register. You will be given a user and a team (separated with “-”). The user is the creator of that team.
For every newly created team you should print a message:
"Team {team Name} has been created by {user}!".
Next you will receive user with team (separated with "->") which means that the user wants to join that team. Upon receiving the command: “end of assignment”, you should print every team, ordered by the count of its members (descending) and then by name (ascending). For each team (disband teams as well), you have to print its members sorted by name (ascending). However, there are several rules:
- If user tries to create a team more than once a message should be displayed:
- "Team {teamName} was already created!"
- Creator of a team cannot create another team - message should be thrown:
- "{user} cannot create another team!"
- If user tries to join currently non-existing team a message should be displayed:
- "Team {teamName} does not exist!"
- Member of a team cannot join another team - message should be thrown:
- "Member {user} cannot join team {team Name}!"
- In the end (after teams' report) teams with zero members (with only a creator) should disband ordered by name in ascending other.
- Every valid team should be printed ordered by name (ascending) in this format:
"{teamName}:
- {create}
-- {member}..."
Входни/Изходни данни:
Input |
Output |
Comments |
2 Didy-PowerPuffsCoders Tony-Tony is the best Petya->PowerPuffsCoders Tony->Tony is the best end of assignment |
Team PowerPuffsCoders has been created by Didy! Team Tony is the best has been created by Tony! Member Tony cannot join team Tony is the best! PowerPuffsCoders - Didy -- Petya Teams to disband: Tony is the best |
Tony created a team that he tried later to join. So the message was shown. Since no one is trying to join his team, the team has to disband. |
3 Tatyana-CloneClub Helena-CloneClub Trifon-BRBClub Peter->bRBClub Peter->BRBClub Tatyana->Leda Petter->BRBClub Cossima->CloneClub end of assignment |
Team CloneClub has been created by Tatyana! Team CloneClub was already created! Team BRBClub has been created by Trifon! Team bRBClub does not exist! Team Leda does not exist! BRBClub - Trifon -- Peter -- Petter CloneClub - Tatyana -- Cossima Teams to disband: |
Note that when you join a team, you should check first if it exists, then check if the user is already in a team: Tatyana has created CloneClub, and then she tries to join a non-existing team – so a message for the non-existing team is shown. |
Кода, който съм написал е следния: https://pastebin.com/a1yiWvf7
Ще съм благодарен, ако ми дадете насоки, затова къде греша.
Много благодаря, колега! Това беше разковничето, но който не дочита или не прочита правилно - така ще е.
Още веднъж благодарности! :)