05. Teamwork Projects (Objects and Classes Exercise)
Здравейте,
Последният тест ми дава грешен отговор със следното съобщение: "The process executing your submission for this test may not have received the output successfully. Please try to submit again the same solution. If the result does not change, then search the error in the submission itself."
Не успявам да открия грешката си. Моля за помощ :)
Това е кодът ми: https://pastebin.com/tinSHZZx
Това е условието:
Teamwork Projects
It's time for the teamwork projects and you are responsible for gathering 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 the team. For every newly created team you should print a message:
"Team {teamName} has been created by {user}!".
Next, you will receive а user with a 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, 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!"
- A creator of a team cannot create another team – the following message should be thrown:
- "{user} cannot create another team!"
- If а user tries to join a non-existent team, a message should be displayed:
- "Team {teamName} does not exist!"
- A member of a team cannot join another team – the following message should be thrown:
- "Member {user} cannot join team {team Name}!"
- In the end, teams with zero members (with only a creator) should disband and you have to print them ordered by name in ascending order.
- Every valid team should be printed ordered by name (ascending) in the following format:
"{teamName}: - {creator} -- {member}…" |
Examples
Input |
Output |
Comments |
2 Didi-PowerPuffsCoders Toni-Toni is the best Petq->PowerPuffsCoders Toni->Toni is the best end of assignment |
Team PowerPuffsCoders has been created by Didi! Team Toni is the best has been created by Toni! Member Toni cannot join team Toni is the best! PowerPuffsCoders - Didi -- Petq Teams to disband: Toni is the best |
Toni created a team, which he attempted to join later and this action resulted in throwing a certain message. Since nobody else tried to join his team, the team had to disband. |
3 Tatyana-CloneClub Helena-CloneClub Trifon-SoftUni Pesho->softUni Pesho->SoftUni Tatyana->Leda PeshO->SoftUni Cossima->CloneClub end of assignment |
Team CloneClub has been created by Tatyana! Team CloneClub was already created! Team SoftUni has been created by Trifon! Team softUni does not exist! Team Leda does not exist! SoftUni - Trifon -- Pesho -- PeshO CloneClub - Tatyana -- Cossima Teams to disband: |
Note that when a user joins a team, you should first check if the team exists and then check if the user is already in a team:
Tatyana has created CloneClub, then she tried to join a non-existent team and the concrete message was displayed. |